本文整理汇总了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_);
}
示例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());
}
}
示例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];
}
示例4: assign
void assign(const surface& s)
{
assign_surface_internal(s.get());
}
示例5:
surface(const surface& s) : surface_(s.get())
{
add_surface_ref(surface_);
}
示例6:
bool operator<(const surface& a, const surface& b)
{
return a.get() < b.get();
}