Get map screenshots working again.
This commit is contained in:
parent
072c22f874
commit
05d36f77aa
4 changed files with 41 additions and 12 deletions
|
@ -808,10 +808,10 @@ surface display::screenshot(bool map_screenshot)
|
|||
auto clipper = video().set_clip(area);
|
||||
|
||||
map_screenshot_ = true;
|
||||
invalidateAll_ = true;
|
||||
dirty_ = true;
|
||||
|
||||
DBG_DP << "draw() call for map screenshot\n";
|
||||
draw(true, true);
|
||||
draw();
|
||||
|
||||
map_screenshot_ = false;
|
||||
|
||||
|
@ -1655,7 +1655,7 @@ void display::draw_wrap(bool update, bool force)
|
|||
time_between_draws = 1000 / screen_.current_refresh_rate();
|
||||
}
|
||||
|
||||
if(redrawMinimap_) {
|
||||
if(redrawMinimap_ && !map_screenshot_) {
|
||||
redrawMinimap_ = false;
|
||||
draw_minimap();
|
||||
}
|
||||
|
@ -2453,7 +2453,9 @@ void display::draw(bool update, bool force)
|
|||
}
|
||||
drawing_buffer_commit();
|
||||
post_commit();
|
||||
draw_sidebar();
|
||||
if (!map_screenshot_) {
|
||||
draw_sidebar();
|
||||
}
|
||||
}
|
||||
draw_wrap(update, force);
|
||||
post_draw();
|
||||
|
@ -2592,6 +2594,7 @@ void display::draw_hex(const map_location& loc)
|
|||
|
||||
// Paint mouseover overlays
|
||||
if(loc == mouseoverHex_ && (on_map || (in_editor() && get_map().on_board_with_border(loc)))
|
||||
&& !map_screenshot_
|
||||
&& mouseover_hex_overlay_ != nullptr) {
|
||||
// TODO: highdpi - texture, yes this is terrible
|
||||
drawing_buffer_add(LAYER_MOUSEOVER_OVERLAY, loc, dest, texture(mouseover_hex_overlay_));
|
||||
|
|
|
@ -84,7 +84,7 @@ void editor_display::draw_hex(const map_location& loc)
|
|||
int xpos = get_location_x(loc);
|
||||
int ypos = get_location_y(loc);
|
||||
display::draw_hex(loc);
|
||||
if (map().on_board_with_border(loc)) {
|
||||
if (map().on_board_with_border(loc) && !map_screenshot_) {
|
||||
if (map().in_selection(loc)) {
|
||||
const texture& tex = image::get_texture(
|
||||
"editor/selection-overlay.png", image::TOD_COLORED);
|
||||
|
|
|
@ -268,7 +268,7 @@ void game_display::draw_hex(const map_location& loc)
|
|||
return;
|
||||
}
|
||||
|
||||
if(on_map && loc == mouseoverHex_) {
|
||||
if(on_map && loc == mouseoverHex_ && !map_screenshot_) {
|
||||
drawing_layer hex_top_layer = LAYER_MOUSEOVER_BOTTOM;
|
||||
const unit *u = resources::gameboard->get_visible_unit(loc, dc_->teams()[viewing_team()] );
|
||||
if( u != nullptr ) {
|
||||
|
|
|
@ -645,7 +645,21 @@ surface CVideo::read_pixels(SDL_Rect* r)
|
|||
WRN_DP << "trying to read pixels with no window" << std::endl;
|
||||
return surface();
|
||||
}
|
||||
SDL_Rect d = draw_area();
|
||||
SDL_Rect d;
|
||||
|
||||
// Get the full target area.
|
||||
SDL_Texture* target = SDL_GetRenderTarget(*window);
|
||||
const bool default_target = !target || target == render_texture_;
|
||||
if (default_target) {
|
||||
d = draw_area();
|
||||
} else {
|
||||
// Assume it's a custom render target.
|
||||
int w, h;
|
||||
SDL_QueryTexture(target, nullptr, nullptr, &w, &h);
|
||||
d = {0, 0, w, h};
|
||||
}
|
||||
|
||||
// Intersect with the given rect.
|
||||
SDL_Rect r_clipped = d;
|
||||
if (r) {
|
||||
r_clipped = sdl::intersect_rects(*r, d);
|
||||
|
@ -656,12 +670,24 @@ surface CVideo::read_pixels(SDL_Rect* r)
|
|||
*r = r_clipped;
|
||||
}
|
||||
}
|
||||
SDL_Rect o = to_output(r_clipped);
|
||||
|
||||
// Convert the rect to output coordinates, if necessary.
|
||||
SDL_Rect o;
|
||||
if (default_target) {
|
||||
o = to_output(r_clipped);
|
||||
} else {
|
||||
// r assumed to already be in output space.
|
||||
o = r_clipped;
|
||||
}
|
||||
|
||||
// Create surface and read pixels
|
||||
surface s(o.w, o.h);
|
||||
// the draw-space viewport may be slightly offset on the render target,
|
||||
// if the scale doesn't match precisely with the window size.
|
||||
o.x += offset_x_;
|
||||
o.y += offset_y_;
|
||||
if (default_target) {
|
||||
// the draw-space viewport may be slightly offset on the render target,
|
||||
// if the scale doesn't match precisely with the window size.
|
||||
o.x += offset_x_;
|
||||
o.y += offset_y_;
|
||||
}
|
||||
SDL_RenderReadPixels(*window, &o, s->format->format, s->pixels, s->pitch);
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue