当前位置: 首页>>代码示例>>C++>>正文


C++ surface::get方法代码示例

本文整理汇总了C++中surface::get方法的典型用法代码示例。如果您正苦于以下问题:C++ surface::get方法的具体用法?C++ surface::get怎么用?C++ surface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在surface的用法示例。


在下文中一共展示了surface::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: append_text

void textbox::append_text(const std::string& text, bool auto_scroll, const SDL_Color& color)
{
	if(text_image_.get() == NULL) {
		set_text(text, color);
		return;
	}

	//disallow adding multi-line text to a single-line text box
	if(wrap_ == false && std::find_if(text.begin(),text.end(),utils::isnewline) != text.end()) {
		return;
	}
	const bool is_at_bottom = get_position() == get_max_position();
	const wide_string& wtext = utils::string_to_wstring(text);

	const surface new_text = add_text_line(wtext, color);
	const surface new_surface = create_compatible_surface(text_image_,std::max<size_t>(text_image_->w,new_text->w),text_image_->h+new_text->h);

	SDL_SetAlpha(new_text.get(),0,0);
	SDL_SetAlpha(text_image_.get(),0,0);

	SDL_BlitSurface(text_image_,NULL,new_surface,NULL);

	SDL_Rect target = {0,text_image_->h,new_text->w,new_text->h};
	SDL_BlitSurface(new_text,NULL,new_surface,&target);
	text_image_.assign(new_surface);

	text_.resize(text_.size() + wtext.size());
	std::copy(wtext.begin(),wtext.end(),text_.end()-wtext.size());

	set_dirty(true);
	update_text_cache(false);
	if(auto_scroll && is_at_bottom) scroll_to_bottom();
	handle_text_changed(text_);
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:34,代码来源:textbox.cpp

示例2: run_formula

void run_formula(surface surf, const std::string& algo)
{
	const hi_res_timer timer("run_formula");

	const int ticks = SDL_GetTicks();
	surface_formula_symbol_table table(surf);
	game_logic::formula f(algo, &table);
	bool locked = false;
	if(SDL_MUSTLOCK(surf.get())) {
		const int res = SDL_LockSurface(surf.get());
		if(res == 0) {
			locked = true;
		}
	}

	std::map<Uint32, Uint32> pixel_map;

	Uint32* pixels = reinterpret_cast<Uint32*>(surf->pixels);
	Uint32* end_pixels = pixels + surf->w*surf->h;

	Uint32 AlphaPixel = SDL_MapRGBA(surf->format, 0x6f, 0x6d, 0x51, 0x0);

	int skip = 0;
	while(pixels != end_pixels) {
		if(((*pixels)&(~surf->format->Amask)) == AlphaPixel) {
			++pixels;
			continue;
		}
		std::map<Uint32, Uint32>::const_iterator itor = pixel_map.find(*pixels);
		if(itor == pixel_map.end()) {
			pixel_callable p(surf, *pixels);
			Uint32 result = f.execute(p).as_int();
			pixel_map[*pixels] = result;
			*pixels = result;
		} else {
			*pixels = itor->second;
		}
		++pixels;
	}

	if(locked) {
		SDL_UnlockSurface(surf.get());
	}
}
开发者ID:davewx7,项目名称:Wizard-Tactics,代码行数:44,代码来源:surface_formula.cpp

示例3: get_cursor

static SDL_Cursor* get_cursor(cursor::CURSOR_TYPE type)
{
	bool is_color = use_color_cursors();
	if(cache[type] == NULL || indeterminate(cache_color[type]) || cache_color[type] != is_color) {
		const std::string prefix = is_color ? "cursors/" : "cursors-bw/";
		const surface surf(image::get_image(prefix + (is_color ? color_images : bw_images)[type]));
		if (is_color) {
			cache[type] = SDL_CreateColorCursor(surf.get(), shift_x[type], shift_y[type]);
		} else {
			cache[type] = create_cursor(surf);
		}
		cache_color[type] = is_color;
	}

	return cache[type];
}
开发者ID:quyetdx55,项目名称:wesnoth,代码行数:16,代码来源:cursor.cpp

示例4: assign

	void assign(const surface& s)
	{
		assign_surface_internal(s.get());
	}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:4,代码来源:surface.hpp

示例5:

	surface(const surface& s) : surface_(s.get())
	{
		add_surface_ref(surface_);
	}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:4,代码来源:surface.hpp

示例6:

bool operator<(const surface& a, const surface& b)
{
	return a.get() < b.get();
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:4,代码来源:surface.cpp


注:本文中的surface::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。