void optmize_panorama() {

		for (int level = 2; level >= 0; level--) {
			for (int i = 0; i < (level + 1) * (level + 1) * 10; i++) {
				float max_update = map->optimize_panorama(level);

				pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud =
						map->get_map_pointcloud();

				update_map();

				cloud->header.frame_id = "/cloudbot1/odom";
				cloud->header.stamp = ros::Time::now();
				cloud->header.seq = 0;
				pointcloud_pub.publish(cloud);

				usleep(100000);

				if (max_update < 1e-4)
					break;
			}
		}

		update_map(true);

	}
Ejemplo n.º 2
0
void robot_mapper::optmize_panorama() {

	for (int level = 2; level >= 0; level--) {
		for (int i = 0; i < (level + 1) * (level + 1) * 10; i++) {
			float max_update = map->optimize_panorama(level);

			pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud =
					map->get_map_pointcloud();

			update_map();

			publish_cloud();

			//usleep(100000);

			if (max_update < 1e-4)
				break;
		}
	}

	map->align_z_axis();
	update_map(true);
	publish_cloud();

	skip_first_n_in_optimization = map->frames.size();

}
Ejemplo n.º 3
0
void SimpleWordMapper::map(Output& first, Output& another) {
    first.total_word_count += another.total_word_count;
    std::map<Term, size_t>::const_iterator iter;
    for (iter = another.terms.begin(); iter != another.terms.end(); iter++) {
        update_map((*iter).first, (*iter).second, first.terms, first);
    }
    for (iter = another.basic_words.begin(); iter != another.basic_words.end(); iter++) {
        update_map((*iter).first, (*iter).second, first.basic_words, first);
    }
}
Ejemplo n.º 4
0
char *
dimm_map(int cpu, int dimm)
{
    int i = sys.imap;
    int j;
    char *status = NULL;

    update_map(); /* based on smbios' product name */

    if (sys.imap == -1) return (status);
    i = sys.imap;
    if (verbose) printf("platform = %s\n", maps[i].platform);

    for (j = 0; maps[i].map[j].silkscreen != NULL; j++) {
	if ((maps[i].map[j].cpu == cpu) &&
	    (maps[i].map[j].dimm == dimm)) {
		if (verbose) printf(" cpu=%d, dimm=%d, silkscreen=%s \n",
			maps[i].map[j].cpu,
			maps[i].map[j].dimm,
			maps[i].map[j].silkscreen);
		status = maps[i].map[j].silkscreen;
		break;
	}
    }
    cleanup_dimm();
    return (status);
}
Ejemplo n.º 5
0
void screen_map_update_location() {

    if ((xposprev - s_gpsdata.xpos)*(xposprev - s_gpsdata.xpos) + (yposprev - s_gpsdata.ypos)*(yposprev - s_gpsdata.ypos) < 5*5) {
        // distance with previous position < 4*10 (m)
        /*snprintf(s_data.debug2, sizeof(s_data.debug2),
          "#11 nbpoints:%u\npos : %ld|%ld\nposprev : %ld|%ld\n",
          nb_points,
          s_gpsdata.xpos, s_gpsdata.ypos,
          xposprev, yposprev
        );*/
        return;
    }
    //vibes_short_pulse();
    xposprev = s_gpsdata.xpos;
    yposprev = s_gpsdata.ypos;

    cur_point = nb_points % NUM_POINTS;
    nb_points++;

    pts[cur_point] = GPoint(s_gpsdata.xpos, s_gpsdata.ypos);


    if (s_data.page_number == PAGE_MAP) {
        // refresh displayed map only if current page is PAGE_MAP
        update_map(false);
    }

}
Ejemplo n.º 6
0
static void init_iso8859_5(void)
{
	setupmaps();

/* MSDOS Code Page 866 -> ISO8859-5 */
update_map("\260\200\261\201\262\202\263\203\264\204\265\205\266\206\267\207");
update_map("\270\210\271\211\272\212\273\213\274\214\275\215\276\216\277\217");
update_map("\300\220\301\221\302\222\303\223\304\224\305\225\306\226\307\227");
update_map("\310\230\311\231\312\232\313\233\314\234\315\235\316\236\317\237");
update_map("\320\240\321\241\322\242\323\243\324\244\325\245\326\246\327\247");
update_map("\330\250\331\251\332\252\333\253\334\254\335\255\336\256\337\257");
update_map("\340\340\341\341\342\342\343\343\344\344\345\345\346\346\347\347");
update_map("\350\350\351\351\352\352\353\353\354\354\355\355\356\356\357\357");
update_map("\241\360\361\361\244\362\364\363\247\364\367\365\256\366\376\367");
update_map("\360\374\240\377");
}
Ejemplo n.º 7
0
static int	mouve_map_ex(int k, t_all *all)
{
	if (k == 0)
		all->pos.x -= 10;
	else if (k == 1)
		all->pos.y += 10;
	else if (k == 2)
		all->pos.x += 10;
	else if (k == 31)
		reset(all);
	else if (k == 53)
		exit(0);
	else if (k == 15)
		all->pos.refx -= 1;
	else if (k == 17)
		all->pos.refx += 1;
	else if (k == 3)
		all->pos.refy -= 1;
	else if (k == 5)
		all->pos.refy += 1;
	else if (k == 8)
		all->pos.refz -= 1;
	else if (k == 9)
		all->pos.refz += 1;
	else
		return (0);
	return (update_map(all->mlx, all->win, all->object, all->pos));
}
Ejemplo n.º 8
0
// We are shifting windows.  That means we are moving all %i to %o,
// getting rid of all current %l, and keeping all %g.  This is only
// complicated if any of the location pointers for these are valid.
// The normal case is that everything is in its standard register window
// home, and _location_valid[0] is zero.  In that case, this routine
// does exactly nothing.
void RegisterMap::shift_individual_registers() {
  if (!update_map())  return;  // this only applies to maps with locations
  register_map_init();
  check_location_valid();

  LocationValidType lv = _location_valid[0];
  LocationValidType lv0 = lv;

  lv &= ~R_LIO_mask;  // clear %l, %o, %i regs

  // if we cleared some non-%g locations, we may have to do some shifting
  if (lv != lv0) {
    // copy %i0-%i5 to %o0-%o5, if they have special locations
    // This can happen in within stubs which spill argument registers
    // around a dynamic link operation, such as resolve_opt_virtual_call.
    for (int i = 0; i < 8; i++) {
      if (lv0 & (1LL << R_I_nums[i])) {
        _location[R_O_nums[i]] = _location[R_I_nums[i]];
        lv |=  (1LL << R_O_nums[i]);
      }
    }
  }

  _location_valid[0] = lv;
  check_location_valid();
}
Ejemplo n.º 9
0
void screen_map_zoom_out(int factor) {
    map_scale = map_scale * factor;
    if (map_scale > MAP_SCALE_MAX) {
        map_scale = MAP_SCALE_MIN;
    }
    update_map(true);
}
Ejemplo n.º 10
0
void screen_map_zoom_in(int factor) {
    map_scale = map_scale / factor;
    if (map_scale < MAP_SCALE_MIN) {
        map_scale = MAP_SCALE_MAX;
    }
    update_map(true);
}
Ejemplo n.º 11
0
int		generate_minerals(t_server *s)
{
  t_counters	count;

  count.i = -1;
  count.save_j = 0;
  s->minerals_consumed = 0;
  while (++count.i < NUM_MIN)
    {
      count.save_i = s->max_num_minerals - s->current_num_minerals[count.i];
      if (count.save_i > 0)
	{
	  count.save_j = 1;
	  count.j = -1;
	  while (++count.j < count.save_i)
	    {
	      if (add_stone(count.i, s) == -1)
		return (-1);
	      s->current_num_minerals[count.i]++;
	    }
	}
    }
  if (count.save_j != 0)
    update_map(s);
  return (0);
}
Ejemplo n.º 12
0
Archivo: main.c Proyecto: Df458/Growgue
bool update_game()
{
    int in = get_input(get_map_window());
    if(in == INPUT_ACTION && get_last_action() == ACTION_QUIT)
        return false;
    else if(in == INPUT_ACTION && (get_last_action() == ACTION_SCROLL_UP || get_last_action() == ACTION_SCROLL_DOWN)) {
        log_scroll(get_last_action() == ACTION_SCROLL_UP);
        draw_log();
    } else if(!dead) {
        update_player();
        if(get_current_floor() != current_level) {
            set_current_map(world[get_current_floor()], current_level < get_current_floor(), current_level > get_current_floor());
            current_level = get_current_floor();
        }
        update_map(1, world[current_level]);
        if(is_dead()) {
            add_message(COLOR_HP_CRIT, "Oh dear, you've died!");
            add_message(COLOR_DEFAULT, "Press q to return to the main menu");
            dead = true;
        }
        if(game_won())
            dead = true;
        draw_log();
    }
    return true;
}
Ejemplo n.º 13
0
int			mouve_map(int k, t_all *all)
{
	if (k == 69)
		all->pos.zoom++;
	else if (k == 78)
		all->pos.zoom--;
	else if (k == 126)
		all->pos.a += 0.05;
	else if (k == 125)
		all->pos.a -= 0.05;
	else if (k == 123)
		all->pos.c += 0.05;
	else if (k == 124)
		all->pos.c -= 0.05;
	else if (k == 47)
		all->pos.b += 0.05;
	else if (k == 43)
		all->pos.b -= 0.05;
	else if (k == 34)
		all->pos.zoom_z++;
	else if (k == 32)
		all->pos.zoom_z--;
	else if (k == 13)
		all->pos.y -= 10;
	else
		return (mouve_map_ex(k, all));
	return (update_map(all->mlx, all->win, all->object, all->pos));
}
Ejemplo n.º 14
0
void upnp::delete_mapping(int mapping)
{
	mutex::scoped_lock l(m_mutex);

	if (mapping >= int(m_mappings.size())) return;

	global_mapping_t& m = m_mappings[mapping];

	char msg[500];
	snprintf(msg, sizeof(msg), "deleting port map: [ protocol: %s ext_port: %u "
		"local_port: %u ]", (m.protocol == tcp?"tcp":"udp"), m.external_port
		, m.local_port);
	log(msg, l);

	if (m.protocol == none) return;
	
	for (std::set<rootdevice>::iterator i = m_devices.begin()
		, end(m_devices.end()); i != end; ++i)
	{
		rootdevice& d = const_cast<rootdevice&>(*i);
		TORRENT_ASSERT(d.magic == 1337);

		TORRENT_ASSERT(mapping < int(d.mapping.size()));
		d.mapping[mapping].action = mapping_t::action_delete;

		if (d.service_namespace) update_map(d, mapping, l);
	}
}
Ejemplo n.º 15
0
void robot_mapper::optmize() {

	if (map->frames.size() < 2)
		return;

	map->optimize_slam(skip_first_n_in_optimization);
	publish_cloud();
	update_map();

}
Ejemplo n.º 16
0
void SimpleWordMapper::map(std::vector<Term>& terms, std::map<Term, 
                                        size_t>& target, Output& output) {
    if (terms.size() == 0) {
        return;
    }
    std::sort(terms.begin(), terms.end());
    Term term = terms[0];
    size_t count = 1;
    for (size_t i = 1, i_end = terms.size(); i < i_end; i++) {
        if (terms[i] == term) {
            count++;
        }
        else {
            update_map(term, count, target, output);
            term = terms[i];
            count = 1;
        }
    }
    update_map(term, count, target, output);
}
Ejemplo n.º 17
0
// returns a reference to a mapping or -1 on failure
int upnp::add_mapping(upnp::protocol_type p, int external_port, int local_port)
{
	// external port 0 means _every_ port
	TORRENT_ASSERT(external_port != 0);

	mutex::scoped_lock l(m_mutex);

	char msg[500];
	snprintf(msg, sizeof(msg), "adding port map: [ protocol: %s ext_port: %u "
		"local_port: %u ] %s", (p == tcp?"tcp":"udp"), external_port
		, local_port, m_disabled ? "DISABLED": "");
	log(msg, l);
	if (m_disabled) return -1;

	std::vector<global_mapping_t>::iterator i = std::find_if(
		m_mappings.begin(), m_mappings.end()
		, boost::bind(&global_mapping_t::protocol, _1) == int(none));

	if (i == m_mappings.end())
	{
		m_mappings.push_back(global_mapping_t());
		i = m_mappings.end() - 1;
	}

	i->protocol = p;
	i->external_port = external_port;
	i->local_port = local_port;

	int mapping_index = i - m_mappings.begin();

	for (std::set<rootdevice>::iterator i = m_devices.begin()
		, end(m_devices.end()); i != end; ++i)
	{
		rootdevice& d = const_cast<rootdevice&>(*i);
		TORRENT_ASSERT(d.magic == 1337);

		if (int(d.mapping.size()) <= mapping_index)
			d.mapping.resize(mapping_index + 1);
		mapping_t& m = d.mapping[mapping_index];

		m.action = mapping_t::action_add;
		m.protocol = p;
		m.external_port = external_port;
		m.local_port = local_port;

		if (d.service_namespace) update_map(d, mapping_index, l);
	}

	return mapping_index;
}
Ejemplo n.º 18
0
Archivo: charcnv.c Proyecto: artzub/mc
static void init_iso8859_5(void)
{
  int i;
  if (!mapsinited) initmaps();

  /* Do not map undefined characters to some accidental code */
  for (i = 128; i < 256; i++) 
  {
     unix2dos[i] = CTRLZ;
     dos2unix[i] = CTRLZ;
  }

/* MSDOS Code Page 866 -> ISO8859-5 */
update_map("\260\200\261\201\262\202\263\203\264\204\265\205\266\206\267\207");
update_map("\270\210\271\211\272\212\273\213\274\214\275\215\276\216\277\217");
update_map("\300\220\301\221\302\222\303\223\304\224\305\225\306\226\307\227");
update_map("\310\230\311\231\312\232\313\233\314\234\315\235\316\236\317\237");
update_map("\320\240\321\241\322\242\323\243\324\244\325\245\326\246\327\247");
update_map("\330\250\331\251\332\252\333\253\334\254\335\255\336\256\337\257");
update_map("\340\340\341\341\342\342\343\343\344\344\345\345\346\346\347\347");
update_map("\350\350\351\351\352\352\353\353\354\354\355\355\356\356\357\357");
update_map("\241\360\361\361\244\362\364\363\247\364\367\365\256\366\376\367");
update_map("\360\374\240\377");
}
Ejemplo n.º 19
0
// Manejador de eventos de teclado en GUI.
void key(unsigned char k, int x, int y)
{
	switch (k) {
	case 'p':
		opt.paused ^= true;
		update_map(0);
		break;
	case 'q':
		exit(0);
		break;
	case 'a':
		opt.automatic ^= true;
		update_map(0);
		break;
	case 'z':
		opt.zoom += opt.zoom * 0.05f;
		break;
	case 'x':
		if (opt.zoom >= 1.05f) {
			opt.zoom -= opt.zoom * 0.05f;
		}
		break;
	case 43:	// +
		if (opt.period > 5) {
			opt.period -= 5;
		}
		break;
	case 45:	// -
		opt.period += 5;
		break;
	default:
		if (opt.automatic == false) {
			update_map(0);
		}
	}
}
Ejemplo n.º 20
0
// realize_main: Called when map_area is realized
// ------------------------------------------- >>
static void realize_main(GtkWidget *widget, gpointer data)
{
	//GdkGLContext *glcontext = gtk_widget_get_gl_context(widget);
	GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);

	if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
		return;

	vid_width = widget->allocation.width;
	vid_height = widget->allocation.height;
	init_opengl();
	update_map();
	update_grid();

	gdk_gl_drawable_gl_end (gldrawable);
}
void Chrome_Extractor::extract_search() {
	{
		SQLITE_OPEN(file)

		QSqlQuery	query(db);

		query.exec("SELECT term, COUNT(*) FROM keyword_search_terms GROUP BY term;");

		while (query.next()) {
			update_map(keyword_map, query.value(0).toString(), query.value(1).toUInt());
		}

		query.clear();
	}
	SQLITE_CLOSE(file)
}
void Chrome_Extractor::extract_places() {
	{
		SQLITE_OPEN(file)
		// TODO: remove last "/" using the regex
		// perl -pe 's/^https*:\/\/(.*?)\/.*?$/$1/'
		QSqlQuery	query(db);
//#ifdef WINDOWS_OS
//		QRegExp	url_cleaner("^https{0,1}\:\/\/(.+)(\/.*|$)");
//		QRegExp slash_cleaner("\/$");
//#else
		QRegExp	url_cleaner("^https{0,1}\\:\\/\\/(.+)(\\/.*|\\/|$)");
		QRegExp slash_cleaner("\\/$");
//#endif
		url_cleaner.setMinimal(true);

		/*
		 * rebuilding the history:
		 *
		 * select urls.url, visits.visit_time from urls, visits where urls.id = visits.url
		 * select urls.url, urls.title, urls.visit_count, urls.typed_count,
		 *	datetime( urls.last_visit_time/1000000-11644473600, 'unixepoch' ) as lastvisit_date ,
		 *	urls.hidden, visits.visit_time, visits.from_visit, visits.transition
		 *	from urls, visits
		 *	where urls.id = visits.url;
		 *
		 * TODO: add the last_visit_time to the database
		 * Take care of Window's time convertion to UNIX timestamp
		 */
		query.exec("SELECT visit_count, url FROM urls ORDER BY visit_count DESC, url ASC;");

		while (query.next()) {
			QString cleaned_url = "";

			if ( url_cleaner.indexIn(query.value(1).toString()) != -1 ) {
				cleaned_url = url_cleaner.cap(1);
				cleaned_url.replace(slash_cleaner, "");

				update_map(url_map, cleaned_url, query.value(0).toUInt());
			} else
				qDebug() << "Regex failed on " << query.value(1).toString();
		}
		query.clear();
	}
	SQLITE_CLOSE(file)
}
	void optmize() {

		if (map->frames.size() < 2)
			return;

		map->optimize_slam();

		pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud =
				map->get_map_pointcloud();

		cloud->header.frame_id = "odom";
		cloud->header.stamp = ros::Time::now();
		cloud->header.seq = 0;
		pointcloud_pub.publish(cloud);

		update_map();

	}
Ejemplo n.º 24
0
// force_map_redraw: Forces the map area to be redrawn
// ------------------------------------------------ >>
void force_map_redraw(bool map, bool grid)
{
	GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(map_area);

	if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
		return;

	if (grid)
		update_grid();

	if (map)
		update_map();

	gdk_gl_drawable_gl_end(gldrawable);

	gdk_window_invalidate_rect(map_area->window, &map_area->allocation, false);
	update_status_bar();
	//render_map();
}
int main(int argc, char *argv[]) {
    pid_t child_pid;

    if (argc < 2)
        return 1;

    child_pid = clone(
            child,
            child_stack + STACK_SIZE,
            CLONE_NEWNS | CLONE_NEWPID | CLONE_NEWUTS | CLONE_NEWUSER | SIGCHLD,
            argv[1]);

    printf("PID of child: %ld\n", (long) child_pid);
    update_map(0, 1000, 1, child_pid);

    waitpid(child_pid, NULL, 0);

    return 0;
}
Ejemplo n.º 26
0
/*
** Print on the map the grass [prepare the surface ans blit]
*/
void		print_init_map(t_sdl *sdl)
{
  SDL_Rect	screen_pos;
  int		x;
  int		y;

  x = sdl->scrollX;
  init_rect(&screen_pos);
  screen_pos.h = SCREEN_H;
  screen_pos.w = SCREEN_W;
  while (x < map_size.x && x - sdl->scrollX < SCREEN_H / 64)
    {
      y = sdl->scrollY;
      while (y < map_size.y && y - sdl->scrollY < (SCREEN_W - 192) / 64)
	{
	  update_map(sdl, &screen_pos, x, y);
	  y++;
	}
      x++;
    }
}
Ejemplo n.º 27
0
int sync_maps(sd_bus *bus, sd_bus_slot *slot)
{
        struct dmmp_context *ctx = NULL;
        struct dmmp_mpath **maps = NULL;
        uint32_t dmmp_mp_count = 0;
        const char *name = NULL;
        const char *wwid = NULL;
        uint32_t i = 0;
        int rc = EXIT_SUCCESS;

        ctx = dmmp_context_new();
        dmmp_context_log_priority_set(ctx, DMMP_LOG_PRIORITY_DEBUG);
        dmmp_context_userdata_set(ctx, ctx);
        dmmp_context_userdata_set(ctx, NULL);
        dmmp_context_timeout_set(ctx, TMO);
        if (dmmp_context_timeout_get(ctx) != TMO)
                printf("dmmp_context_timeout_set(): Failed to set "
                     "timeout to %u", TMO);

        if (dmmp_mpath_array_get(ctx, &maps, &dmmp_mp_count) != 0)
        	printf("dmmp_mpath_array_get(): rc != 0\n");
        if (dmmp_mp_count == 0)
        	printf("dmmp_mpath_array_get(): "
                     "Got no multipath devices\n");

        for (i = 0; i < dmmp_mp_count; ++i) {

                update_map(bus, slot, maps[i]);


        }

//	TODO fix memory leak/resource problems
//        dmmp_mpath_array_free(maps, dmmp_mp_count);
out:
//        dmmp_context_free(ctx);

        return 0;
}
Ejemplo n.º 28
0
int main(int argc, char** argv)
{
    GLFWwindow window;
    int ch, iter;
    double dt;
    double last_update_time;
    int frame;
    float f;
    GLint uloc_modelview;
    GLint uloc_project;

    char* vertex_shader_path = NULL;
    char* fragment_shader_path = NULL;
    char* vertex_shader_src = NULL;
    char* fragment_shader_src = NULL;
    GLuint shader_program;

    while ((ch = getopt(argc, argv, "f:v:h")) != -1)
    {
        switch (ch)
        {
            case 'f':
                fragment_shader_path = optarg;
                break;
            case 'v':
                vertex_shader_path = optarg;
                break;
            case 'h':
                usage();
                exit(EXIT_SUCCESS);
            default:
                usage();
                exit(EXIT_FAILURE);
        }
    }

    if (fragment_shader_path)
    {
        vertex_shader_src = read_file_content(fragment_shader_path);
        if (!fragment_shader_src)
        {
            fprintf(stderr,
                    "ERROR: unable to load fragment shader from '%s'\n",
                    fragment_shader_path);
            exit(EXIT_FAILURE);
        }
    }

    if (vertex_shader_path)
    {
        vertex_shader_src = read_file_content(vertex_shader_path);
        if (!vertex_shader_src)
        {
            fprintf(stderr,
                    "ERROR: unable to load vertex shader from '%s'\n",
                    fragment_shader_path);
            exit(EXIT_FAILURE);
        }
    }

    if (!glfwInit())
    {
        fprintf(stderr, "ERROR: Unable to initialize GLFW\n");
        usage();

        free(vertex_shader_src);
        free(fragment_shader_src);
        exit(EXIT_FAILURE);
    }

    glfwOpenWindowHint(GLFW_WINDOW_RESIZABLE, GL_FALSE);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);

    window = glfwOpenWindow(800, 600, GLFW_WINDOWED, "GLFW OpenGL3 Heightmap demo", NULL);
    if (! window )
    {
        fprintf(stderr, "ERROR: Unable to create the OpenGL context and associated window\n");
        usage();

        free(vertex_shader_src);
        free(fragment_shader_src);
        exit(EXIT_FAILURE);
    }
    glfwSetWindowCloseCallback(window_close_callback);
    glfwSetKeyCallback(key_callback);
    /* Register events callback */

    if (GL_TRUE != init_opengl())
    {
        fprintf(stderr, "ERROR: unable to resolve OpenGL function pointers\n");
        free(vertex_shader_src);
        free(fragment_shader_src);
        exit(EXIT_FAILURE);
    }
    /* Prepare opengl resources for rendering */
    shader_program = make_shader_program(vertex_shader_src , fragment_shader_src);
    free(vertex_shader_src);
    free(fragment_shader_src);

    if (shader_program == 0u)
    {
        fprintf(stderr, "ERROR: during creation of the shader program\n");
        usage();
        exit(EXIT_FAILURE);
    }

    pglUseProgram(shader_program);
    uloc_project   = pglGetUniformLocation(shader_program, "project");
    uloc_modelview = pglGetUniformLocation(shader_program, "modelview");

    /* Compute the projection matrix */
    f = 1.0f / tanf(view_angle / 2.0f);
    projection_matrix[0]  = f / aspect_ratio;
    projection_matrix[5]  = f;
    projection_matrix[10] = (z_far + z_near)/ (z_near - z_far);
    projection_matrix[11] = -1.0f;
    projection_matrix[14] = 2.0f * (z_far * z_near) / (z_near - z_far);
    pglUniformMatrix4fv(uloc_project, 1, GL_FALSE, projection_matrix);

    /* Set the camera position */
    modelview_matrix[12]  = -5.0f;
    modelview_matrix[13]  = -5.0f;
    modelview_matrix[14]  = -20.0f;
    pglUniformMatrix4fv(uloc_modelview, 1, GL_FALSE, modelview_matrix);

    /* Create mesh data */
    init_map();
    make_mesh(shader_program);

    /* Create vao + vbo to store the mesh */
    /* Create the vbo to store all the information for the grid and the height */

    /* setup the scene ready for rendering */
    glViewport(0, 0, 800, 600);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    /* main loop */
    frame = 0;
    iter = 0;
    dt = last_update_time = glfwGetTime();

    while (running)
    {
        ++frame;
        /* render the next frame */
        glClear(GL_COLOR_BUFFER_BIT);
        glDrawElements(GL_LINES, 2* MAP_NUM_LINES , GL_UNSIGNED_INT, 0);

        /* display and process events through callbacks */
        glfwSwapBuffers();
        glfwPollEvents();
        /* Check the frame rate and update the heightmap if needed */
        dt = glfwGetTime();
        if ((dt - last_update_time) > 0.2)
        {
            /* generate the next iteration of the heightmap */
            if (iter < MAX_ITER)
            {
                update_map(NUM_ITER_AT_A_TIME);
                update_mesh();
                iter += NUM_ITER_AT_A_TIME;
            }
            last_update_time = dt;
            frame = 0;
        }
    }

    exit(EXIT_SUCCESS);
}
Ejemplo n.º 29
0
Archivo: charcnv.c Proyecto: artzub/mc
static void init_koi8_r(void)
{
  if (!mapsinited) initmaps();

  /* There aren't undefined characters between 128 and 255 */

/* MSDOS Code Page 866 -> KOI8-R */
update_map("\200\304\201\263\202\332\203\277\204\300\205\331\206\303\207\264");
update_map("\210\302\211\301\212\305\213\337\214\334\215\333\216\335\217\336");
update_map("\220\260\221\261\222\262\223\364\224\376\225\371\226\373\227\367");
update_map("\230\363\231\362\232\377\233\365\234\370\235\375\236\372\237\366");
update_map("\240\315\241\272\242\325\243\361\244\326\245\311\246\270\247\267");
update_map("\250\273\251\324\252\323\253\310\254\276\255\275\256\274\257\306");
update_map("\260\307\261\314\262\265\263\360\264\266\265\271\266\321\267\322");
update_map("\270\313\271\317\272\320\273\312\274\330\275\327\276\316\277\374");
update_map("\300\356\301\240\302\241\303\346\304\244\305\245\306\344\307\243");
update_map("\310\345\311\250\312\251\313\252\314\253\315\254\316\255\317\256");
update_map("\320\257\321\357\322\340\323\341\324\342\325\343\326\246\327\242");
update_map("\330\354\331\353\332\247\333\350\334\355\335\351\336\347\337\352");
update_map("\340\236\341\200\342\201\343\226\344\204\345\205\346\224\347\203");
update_map("\350\225\351\210\352\211\353\212\354\213\355\214\356\215\357\216");
update_map("\360\217\361\237\362\220\363\221\364\222\365\223\366\206\367\202");
update_map("\370\234\371\233\372\207\373\230\374\235\375\231\376\227\377\232");
}
Ejemplo n.º 30
0
Archivo: charcnv.c Proyecto: artzub/mc
static void init_iso8859_2(void) {

    int i;
    if (!mapsinited) initmaps();

    /* Do not map undefined characters to some accidental code */
    for (i = 128; i < 256; i++) 
    {
       unix2dos[i] = CTRLZ;
       dos2unix[i] = CTRLZ;
    }

/*
 * Tranlation table created by Petr Hubeny <*****@*****.**>
 * Requires client code page = 852
 * and character set = ISO8859-2 in smb.conf
 */

/* MSDOS Code Page 852 -> ISO-8859-2 */
update_map("\241\244\242\364\243\235\244\317\245\225\246\227\247\365");
update_map("\250\371\251\346\252\270\253\233\254\215\256\246\257\275");
update_map("\261\245\262\362\263\210\264\357\265\226\266\230\267\363");
update_map("\270\367\271\347\272\255\273\234\274\253\275\361\276\247\277\276");
update_map("\300\350\301\265\302\266\303\306\304\216\305\221\306\217\307\200");
update_map("\310\254\311\220\312\250\313\323\314\267\315\326\316\327\317\322");
update_map("\320\321\321\343\322\325\323\340\324\342\325\212\326\231\327\236");
update_map("\330\374\331\336\332\351\333\353\334\232\335\355\336\335\337\341");
update_map("\340\352\341\240\342\203\343\307\344\204\345\222\346\206\347\207");
update_map("\350\237\351\202\352\251\353\211\354\330\355\241\356\214\357\324");
update_map("\360\320\361\344\362\345\363\242\364\223\365\213\366\224\367\366");
update_map("\370\375\371\205\372\243\373\373\374\201\375\354\376\356\377\372");
}