本文整理汇总了C++中sdl_blit函数的典型用法代码示例。如果您正苦于以下问题:C++ sdl_blit函数的具体用法?C++ sdl_blit怎么用?C++ sdl_blit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sdl_blit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SDL_VERSION_ATLEAST
void part_ui::render_background()
{
#if SDL_VERSION_ATLEAST(2,0,0)
sdl::draw_solid_tinted_rectangle(
0, 0, video_.getx(), video_.gety(), 0, 0, 0, 1.0,
video_.getSurface()
);
sdl_blit(background_, NULL, video_.getSurface(), NULL);
#else
#ifdef SDL_GPU
GPU_Target *target = get_render_target();
GPU_Clear(target);
for (size_t i = 0; i<background_images_.size(); i++) {
const int x = background_positions_[i].first;
const int y = background_positions_[i].second;
background_images_[i].draw(video_, x, y);
}
#else
sdl::draw_solid_tinted_rectangle(
0, 0, video_.getx(), video_.gety(), 0, 0, 0, 1.0,
video_.getSurface()
);
sdl_blit(background_, NULL, video_.getSurface(), NULL);
#endif
#endif
}
开发者ID:MysteryPoo,项目名称:wesnoth,代码行数:27,代码来源:render.cpp
示例2: clear_background
void dialog_frame::draw_background()
{
if(auto_restore_) {
clear_background();
restorer_ = new surface_restorer(&video_, dim_.exterior);
}
if (dialog_style_.blur_radius) {
surface surf = ::get_surface_portion(video_.getSurface(), dim_.exterior);
surf = blur_surface(surf, dialog_style_.blur_radius, false);
sdl_blit(surf, NULL, video_.getSurface(), &dim_.exterior);
}
if(bg_ == NULL) {
ERR_DP << "could not find dialog background '" << dialog_style_.panel << "'\n";
return;
}
for(int i = 0; i < dim_.interior.w; i += bg_->w) {
for(int j = 0; j < dim_.interior.h; j += bg_->h) {
SDL_Rect src = {0,0,0,0};
src.w = std::min(dim_.interior.w - i, bg_->w);
src.h = std::min(dim_.interior.h - j, bg_->h);
SDL_Rect dst = src;
dst.x = dim_.interior.x + i;
dst.y = dim_.interior.y + j;
sdl_blit(bg_, &src, video_.getSurface(), &dst);
}
}
}
开发者ID:CliffsDover,项目名称:wesnoth_ios,代码行数:29,代码来源:show_dialog.cpp
示例3: image_fg
void mouse_action::set_terrain_mouse_overlay(editor_display& disp, t_translation::t_terrain fg,
t_translation::t_terrain bg)
{
surface image_fg(image::get_image("terrain/"
+ disp.get_map().get_terrain_info(fg).editor_image() + ".png"));
surface image_bg(image::get_image("terrain/"
+ disp.get_map().get_terrain_info(bg).editor_image() + ".png"));
if (image_fg == NULL || image_bg == NULL) {
ERR_ED << "Missing terrain icon\n";
disp.set_mouseover_hex_overlay(NULL);
return;
}
// Create a transparent surface of the right size.
surface image = create_compatible_surface(image_fg, image_fg->w, image_fg->h);
sdl_fill_rect(image,NULL,SDL_MapRGBA(image->format,0,0,0, 0));
// For efficiency the size of the tile is cached.
// We assume all tiles are of the same size.
// The zoom factor can change, so it's not cached.
// NOTE: when zooming and not moving the mouse, there are glitches.
// Since the optimal alpha factor is unknown, it has to be calculated
// on the fly, and caching the surfaces makes no sense yet.
static const Uint8 alpha = 196;
static const int size = image_fg->w;
static const int half_size = size / 2;
static const int quarter_size = size / 4;
static const int offset = 2;
static const int new_size = half_size - 2;
const int zoom = static_cast<int>(size * disp.get_zoom_factor());
// Blit left side
image_fg = scale_surface(image_fg, new_size, new_size);
SDL_Rect rcDestLeft = create_rect(offset, quarter_size, 0, 0);
sdl_blit ( image_fg, NULL, image, &rcDestLeft );
// Blit left side
image_bg = scale_surface(image_bg, new_size, new_size);
SDL_Rect rcDestRight = create_rect(half_size, quarter_size, 0, 0);
sdl_blit ( image_bg, NULL, image, &rcDestRight );
//apply mask so the overlay is contained within the mouseover hex
image = mask_surface(image, image::get_hexmask());
// Add the alpha factor and scale the image
image = scale_surface(adjust_surface_alpha(image, alpha), zoom, zoom);
// Set as mouseover
disp.set_mouseover_hex_overlay(image);
}
开发者ID:AG-Dev,项目名称:wesnoth_ios,代码行数:51,代码来源:mouse_action.cpp
示例4: create_surface
void floating_label::draw(surface screen)
{
if(!visible_) {
buf_.assign(nullptr);
return;
}
if(screen == nullptr) {
return;
}
create_surface();
if(surf_ == nullptr) {
return;
}
if(buf_ == nullptr) {
buf_.assign(create_compatible_surface(screen, surf_->w, surf_->h));
if(buf_ == nullptr) {
return;
}
}
SDL_Rect rect = sdl::create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
const clip_rect_setter clip_setter(screen, &clip_rect_);
sdl_copy_portion(screen,&rect,buf_,nullptr);
sdl_blit(surf_,nullptr,screen,&rect);
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:28,代码来源:floating_label.cpp
示例5: inner_location
void textbox::draw_contents()
{
SDL_Rect const &loc = inner_location();
surface surf = video().getSurface();
draw_solid_tinted_rectangle(loc.x,loc.y,loc.w,loc.h,0,0,0,
focus(NULL) ? alpha_focus_ : alpha_, surf);
SDL_Rect src;
if(text_image_ == NULL) {
update_text_cache(true);
}
if(text_image_ != NULL) {
src.y = yscroll_;
src.w = std::min<size_t>(loc.w,text_image_->w);
src.h = std::min<size_t>(loc.h,text_image_->h);
src.x = text_pos_;
SDL_Rect dest = screen_area();
dest.x = loc.x;
dest.y = loc.y;
// Fills the selected area
if(is_selection()) {
const int start = std::min<int>(selstart_,selend_);
const int end = std::max<int>(selstart_,selend_);
int startx = char_x_[start];
int starty = char_y_[start];
const int endx = char_x_[end];
const int endy = char_y_[end];
while(starty <= endy) {
const size_t right = starty == endy ? endx : text_image_->w;
if(right <= size_t(startx)) {
break;
}
SDL_Rect rect = create_rect(loc.x + startx
, loc.y + starty - src.y
, right - startx
, line_height_);
const clip_rect_setter clipper(surf, &loc);
Uint32 color = SDL_MapRGB(surf->format, 0, 0, 160);
fill_rect_alpha(rect, color, 140, surf);
starty += int(line_height_);
startx = 0;
}
}
sdl_blit(text_image_, &src, surf, &dest);
}
draw_cursor((cursor_pos_ == 0 ? 0 : cursor_pos_ - 1), video());
update_rect(loc);
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:60,代码来源:textbox.cpp
示例6: inner_location
void help_text_area::draw_contents()
{
SDL_Rect const &loc = inner_location();
bg_restore();
surface screen = video().getSurface();
clip_rect_setter clip_rect_set(screen, &loc);
for(std::list<item>::const_iterator it = items_.begin(), end = items_.end(); it != end; ++it) {
SDL_Rect dst = it->rect;
dst.y -= get_position();
if (dst.y < static_cast<int>(loc.h) && dst.y + it->rect.h > 0) {
dst.x += loc.x;
dst.y += loc.y;
if (it->box) {
for (int i = 0; i < box_width; ++i) {
sdl::draw_rectangle(dst.x, dst.y, it->rect.w - i * 2, it->rect.h - i * 2,
0, screen);
++dst.x;
++dst.y;
}
}
sdl_blit(it->surf, NULL, screen, &dst);
}
}
update_rect(loc);
}
开发者ID:PositiveMD,项目名称:wesnoth,代码行数:25,代码来源:help_text_area.cpp
示例7: clip_setter
void halo_impl::effect::unrender()
{
if (!surf_ || !buffer_) {
return;
}
// Shrouded haloes are never rendered unless shroud has been re-placed; in
// that case, unrendering causes the hidden terrain (and previous halo
// frame, when dealing with animated halos) to glitch through shroud. We
// don't need to unrender them because shroud paints over the underlying
// area anyway.
if (loc_.x != -1 && loc_.y != -1 && disp->shrouded(loc_)) {
return;
}
surface& screen = disp->get_screen_surface();
SDL_Rect clip_rect = disp->map_outside_area();
const clip_rect_setter clip_setter(screen, &clip_rect);
// Due to scrolling, the location of the rendered halo
// might have changed; recalculate
const int screenx = disp->get_location_x(map_location::ZERO());
const int screeny = disp->get_location_y(map_location::ZERO());
const int xpos = x_ + screenx - surf_->w/2;
const int ypos = y_ + screeny - surf_->h/2;
SDL_Rect rect = sdl::create_rect(xpos, ypos, surf_->w, surf_->h);
sdl_blit(buffer_,nullptr,screen,&rect);
update_rect(rect);
}
开发者ID:N4tr0n,项目名称:wesnoth,代码行数:32,代码来源:halo.cpp
示例8: image
void unit_palette::draw_item(SDL_Rect& dstrect, const unit_type& u, std::stringstream& tooltip_text) {
surface screen = gui_.video().getSurface();
const std::string filename = u.image();
surface image(image::get_image(filename));
if(image == NULL) {
tooltip_text << "IMAGE NOT FOUND\n";
ERR_ED << "image for terrain: '" << filename << "' not found\n";
image = image::get_image(game_config::images::missing);
if (image == NULL) {
ERR_ED << "Placeholder image not found\n";
return;
}
}
if(image->w != item_size_ || image->h != item_size_) {
image.assign(scale_surface(image,
item_size_, item_size_));
}
sdl_blit(image, NULL, screen, &dstrect);
tooltip_text << u.type_name();
}
开发者ID:ehsan,项目名称:wesnoth,代码行数:25,代码来源:unit_palette.cpp
示例9: update_whole_screen
bool part_ui::render_floating_images()
{
events::raise_draw_event();
update_whole_screen();
skip_ = false;
last_key_ = true;
size_t fi_n = 0;
foreach(floating_image::render_input& ri, imgs_) {
const floating_image& fi = p_.get_floating_images()[fi_n];
if(!ri.image.null()) {
sdl_blit(ri.image, NULL, video_.getSurface(), &ri.rect);
update_rect(ri.rect);
}
if (!skip_)
{
int delay = fi.display_delay(), delay_step = 20;
for (int i = 0; i != (delay + delay_step - 1) / delay_step; ++i)
{
if (handle_interface()) return false;
if (skip_) break;
disp_.delay(std::min<int>(delay_step, delay - i * delay_step));
}
}
++fi_n;
}
return true;
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:33,代码来源:render.cpp
示例10: draw_solid_tinted_rectangle
void part_ui::render_background()
{
draw_solid_tinted_rectangle(
0, 0, video_.getx(), video_.gety(), 0, 0, 0, 1.0,
video_.getSurface()
);
sdl_blit(background_, NULL, video_.getSurface(), &base_rect_);
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:8,代码来源:render.cpp
示例11: target
void CVideo::blit_surface(int x, int y, surface surf, SDL_Rect* srcrect, SDL_Rect* clip_rect)
{
surface target(getSurface());
SDL_Rect dst = create_rect(x, y, 0, 0);
const clip_rect_setter clip_setter(target, clip_rect, clip_rect != NULL);
sdl_blit(surf,srcrect,target,&dst);
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:8,代码来源:video.cpp
示例12: make_neutral_surface
surface darken_function::operator()(const surface &src) const
{
surface ret = make_neutral_surface(src);
surface tod_dark(image::get_image(game_config::images::tod_dark));
if (tod_dark)
sdl_blit(tod_dark, NULL, ret, NULL);
return ret;
}
开发者ID:hyrio,项目名称:War-Of-Kingdom,代码行数:8,代码来源:image_function.cpp
示例13: mask_surface
surface mask_function::operator()(const surface& src) const
{
if(src->w == mask_->w && src->h == mask_->h && x_ == 0 && y_ == 0)
return mask_surface(src, mask_);
SDL_Rect r = create_rect(x_, y_, 0, 0);
surface new_mask = create_neutral_surface(src->w, src->h);
sdl_blit(mask_, NULL, new_mask, &r);
return mask_surface(src, new_mask);
}
开发者ID:hyrio,项目名称:War-Of-Kingdom,代码行数:9,代码来源:image_function.cpp
示例14: sdl_blit
void surface_restorer::restore() const
{
if(surface_.null()) {
return;
}
SDL_Rect dst = rect_;
sdl_blit(surface_, nullptr, target_->getSurface(), &dst);
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:9,代码来源:surface.cpp
示例15: sdl_blit
void part_ui::render_background()
{
sdl::draw_solid_tinted_rectangle(
0, 0, video_.getx(), video_.gety(), 0, 0, 0, 1.0,
video_.getSurface()
);
sdl_blit(background_, NULL, video_.getSurface(), NULL);
// Render the titlebox over the background
render_title_box();
}
开发者ID:sunny975,项目名称:wesnoth,代码行数:10,代码来源:render.cpp
示例16: set_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);
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_blit(text_image_,NULL,new_surface,NULL);
SDL_Rect target = create_rect(0
, text_image_->h
, new_text->w
, new_text->h);
sdl_blit(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:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:38,代码来源:textbox.cpp
示例17: undraw
void undraw(surface screen)
{
if(use_color_cursors() == false) {
return;
}
if(cursor_buf == NULL) {
return;
}
SDL_Rect area = create_rect(cursor_x - shift_x[current_cursor]
, cursor_y - shift_y[current_cursor]
, cursor_buf->w
, cursor_buf->h);
sdl_blit(cursor_buf,NULL,screen,&area);
update_rect(area);
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:17,代码来源:cursor.cpp
示例18: get_rect
void ttrack::impl_draw_background(surface& frame_buffer, int x_offset, int y_offset)
{
tcontrol::impl_draw_background(frame_buffer, x_offset, y_offset);
SDL_Rect rc = get_rect();
if (!background_surf_ || background_surf_->w != w_ || background_surf_->h != h_) {
background_surf_.assign(get_surface_portion(frame_buffer, rc));
} else {
sdl_blit(frame_buffer, &rc, background_surf_, NULL);
}
frame_buffer_ = frame_buffer;
frame_offset_ = tpoint(x_offset + draw_offset_.x, y_offset + draw_offset_.y);
if (callback_timer_) {
callback_timer_(*this, frame_buffer, frame_offset_, state2_, false);
}
}
开发者ID:suxinde2009,项目名称:Rose,代码行数:17,代码来源:track.cpp
示例19: clip_setter
void floating_label::undraw(surface screen)
{
if(screen == nullptr || buf_ == nullptr) {
return;
}
SDL_Rect rect = sdl::create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
const clip_rect_setter clip_setter(screen, &clip_rect_);
sdl_blit(buf_,nullptr,screen,&rect);
move(xmove_,ymove_);
if(lifetime_ > 0) {
--lifetime_;
if(alpha_change_ != 0 && (xmove_ != 0.0 || ymove_ != 0.0) && surf_ != nullptr) {
// fade out moving floating labels
surf_.assign(adjust_surface_alpha_add(surf_,alpha_change_));
}
}
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:18,代码来源:floating_label.cpp
示例20: fill_rect_alpha
void fill_rect_alpha(SDL_Rect &rect, Uint32 color, Uint8 alpha, surface target)
{
if(alpha == SDL_ALPHA_OPAQUE) {
sdl::fill_rect(target,&rect,color);
return;
} else if(alpha == SDL_ALPHA_TRANSPARENT) {
return;
}
surface tmp(create_compatible_surface(target,rect.w,rect.h));
if(tmp == NULL) {
return;
}
SDL_Rect r = {0,0,rect.w,rect.h};
sdl::fill_rect(tmp,&r,color);
SDL_SetAlpha(tmp,SDL_SRCALPHA,alpha);
sdl_blit(tmp,NULL,target,&rect);
}
开发者ID:8680-wesnoth,项目名称:wesnoth-fork-old,代码行数:19,代码来源:rect.cpp
注:本文中的sdl_blit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论