Merge lp:~widelands-dev/widelands/cleanup_game_renderer into lp:widelands

Proposed by SirVer
Status: Merged
Merged at revision: 7305
Proposed branch: lp:~widelands-dev/widelands/cleanup_game_renderer
Merge into: lp:widelands
Prerequisite: lp:~widelands-dev/widelands/use_sdl_image_in_one_place
Diff against target: 1238 lines (+349/-509)
16 files modified
src/editor/CMakeLists.txt (+2/-0)
src/game_io/CMakeLists.txt (+3/-0)
src/graphic/CMakeLists.txt (+44/-17)
src/graphic/colormap.cc (+0/-58)
src/graphic/colormap.h (+0/-51)
src/graphic/game_renderer.cc (+218/-73)
src/graphic/game_renderer.h (+39/-49)
src/graphic/gl/game_renderer.cc (+0/-191)
src/graphic/gl/game_renderer.h (+0/-48)
src/graphic/rendertarget.cc (+0/-1)
src/logic/CMakeLists.txt (+3/-0)
src/map_io/CMakeLists.txt (+1/-0)
src/scripting/CMakeLists.txt (+1/-0)
src/sound/CMakeLists.txt (+1/-0)
src/wui/CMakeLists.txt (+27/-6)
src/wui/mapview.cc (+10/-15)
To merge this branch: bzr merge lp:~widelands-dev/widelands/cleanup_game_renderer
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+243124@code.launchpad.net

Description of the change

This is bart of some chained branches. The base branches need to be merged before this.

Suggested commit message:
- Consolidated GameRenderer and its only base class into one.
- Pulled map renderer and minimap renderer into their own library. It becomes clear that we have basic graphics library and a widelands aware one.
- Removed unused files.

---
We should think about changing the directory layout of src. We have at least a wl/ui (wui) base/ui (ui_basic), wl/scripting (most of it), base/scripting (LuaTable at least) , wl/graphic (game renderer, minimap renderer) and base/graphic (surfaces, texture_atlas and so on).

I do not like the name base/ for the "basic" libraries. The separation is "could be useful for other projects" and "is widelands aware". Suggestions for cool names?

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

global? general? wl-lib? common? core? root? shared?

While we're restructuring, should we separate wl/game and wl/editor?

Revision history for this message
SirVer (sirver) wrote :

I like core and base. I like base the most, but we already have a base/. however, nothing stops use from using base/ui base/graphic and so on and just keep the current base directories in base/

Revision history for this message
GunChleoc (gunchleoc) wrote :

Sounds good to me. Do you want o change the directories in this branch, or shall we have a new branch for that?

Revision history for this message
SirVer (sirver) wrote :

other branch, definitively. this change already got bigger than i wanted it to be and I also want to ships this asap.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed 2 nits myself + tested. LGTM.

I love these graphic changes, Widelands is now noticeably faster on my machine.

review: Approve
Revision history for this message
SirVer (sirver) wrote :

Thanks for the review and the fixes. :)

> I love these graphic changes, Widelands is now noticeably faster on my machine.

Great, that keeps me motivated.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/editor/CMakeLists.txt'
--- src/editor/CMakeLists.txt 2014-10-13 15:04:50 +0000
+++ src/editor/CMakeLists.txt 2014-12-04 20:54:56 +0000
@@ -104,4 +104,6 @@
104 ui_fsmenu104 ui_fsmenu
105 widelands_ball_of_mud105 widelands_ball_of_mud
106 wui106 wui
107 wui_mapview_pixelfunctions
108 wui_overlay_manager
107)109)
108110
=== modified file 'src/game_io/CMakeLists.txt'
--- src/game_io/CMakeLists.txt 2014-11-24 06:31:16 +0000
+++ src/game_io/CMakeLists.txt 2014-12-04 20:54:56 +0000
@@ -27,6 +27,7 @@
27 base_time_string27 base_time_string
28 economy28 economy
29 graphic29 graphic
30 graphic_minimap_renderer
30 io_fileread31 io_fileread
31 io_filesystem32 io_filesystem
32 logic33 logic
@@ -36,4 +37,6 @@
36 profile37 profile
37 scripting38 scripting
38 wui39 wui
40 wui_mapview_pixelfunctions
41 wui_overlay_manager
39)42)
4043
=== modified file 'src/graphic/CMakeLists.txt'
--- src/graphic/CMakeLists.txt 2014-12-03 19:14:07 +0000
+++ src/graphic/CMakeLists.txt 2014-12-04 20:54:56 +0000
@@ -1,5 +1,8 @@
1add_subdirectory(text)1add_subdirectory(text)
22
3# TODO(sirver): Separate this directory into a base directory and one
4# that is Widelands aware (can include logic stuff).
5
3wl_library(graphic_color6wl_library(graphic_color
4 SRCS7 SRCS
5 color.h8 color.h
@@ -77,14 +80,52 @@
77 graphic_surface80 graphic_surface
78)81)
7982
83wl_library(graphic_game_renderer
84 SRCS
85 game_renderer.cc
86 game_renderer.h
87 gl/dither_program.cc
88 gl/dither_program.h
89 gl/fields_to_draw.h
90 gl/road_program.cc
91 gl/road_program.h
92 gl/terrain_program.cc
93 gl/terrain_program.h
94 DEPENDS
95 base_exceptions
96 base_geometry
97 base_log
98 base_macros
99 graphic
100 graphic_image_io
101 graphic_surface
102 io_filesystem
103 logic
104 wui_mapview_pixelfunctions
105 wui_overlay_manager
106)
107
108wl_library(graphic_minimap_renderer
109 SRCS
110 minimap_renderer.cc
111 minimap_renderer.h
112 DEPENDS
113 base_geometry
114 base_macros
115 economy
116 graphic
117 graphic_image
118 graphic_surface
119 logic
120 wui_mapview_pixelfunctions
121)
122
80wl_library(graphic123wl_library(graphic
81 SRCS124 SRCS
82 align.cc125 align.cc
83 align.h126 align.h
84 animation.cc127 animation.cc
85 animation.h128 animation.h
86 colormap.cc
87 colormap.h
88 default_resolution.h129 default_resolution.h
89 diranimations.h130 diranimations.h
90 font.cc131 font.cc
@@ -93,34 +134,21 @@
93 font_handler.h134 font_handler.h
94 font_handler1.cc135 font_handler1.cc
95 font_handler1.h136 font_handler1.h
96 game_renderer.cc
97 game_renderer.h
98 gl/blit_program.cc137 gl/blit_program.cc
99 gl/blit_program.h138 gl/blit_program.h
100 gl/dither_program.cc
101 gl/dither_program.h
102 gl/draw_line_program.cc139 gl/draw_line_program.cc
103 gl/draw_line_program.h140 gl/draw_line_program.h
104 gl/draw_rect_program.cc141 gl/draw_rect_program.cc
105 gl/draw_rect_program.h142 gl/draw_rect_program.h
106 gl/fields_to_draw.h
107 gl/fill_rect_program.cc143 gl/fill_rect_program.cc
108 gl/fill_rect_program.h144 gl/fill_rect_program.h
109 gl/game_renderer.cc
110 gl/game_renderer.h
111 gl/road_program.cc
112 gl/road_program.h
113 gl/system_headers.h145 gl/system_headers.h
114 gl/terrain_program.cc
115 gl/terrain_program.h
116 graphic.cc146 graphic.cc
117 graphic.h147 graphic.h
118 image_transformations.cc148 image_transformations.cc
119 image_transformations.h149 image_transformations.h
120 in_memory_image.cc150 in_memory_image.cc
121 in_memory_image.h151 in_memory_image.h
122 minimap_renderer.cc
123 minimap_renderer.h
124 rendertarget.cc152 rendertarget.cc
125 rendertarget.h153 rendertarget.h
126 richtext.cc154 richtext.cc
@@ -139,7 +167,6 @@
139 base_log167 base_log
140 base_macros168 base_macros
141 build_info169 build_info
142 economy
143 graphic_color170 graphic_color
144 graphic_image171 graphic_image
145 graphic_image_io172 graphic_image_io
@@ -154,6 +181,6 @@
154 profile181 profile
155 scripting182 scripting
156 sound183 sound
157 wui184 wui_overlay_manager
158 wui_text_layout185 wui_text_layout
159)186)
160187
=== removed file 'src/graphic/colormap.cc'
--- src/graphic/colormap.cc 2014-07-17 13:26:23 +0000
+++ src/graphic/colormap.cc 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
1/*
2 * Copyright (C) 2002-2004, 2006, 2009 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include "graphic/colormap.h"
21
22#include <algorithm>
23#include <cassert>
24#include <cstdlib>
25#include <cstring>
26
27/**
28 * Create a new Colormap, taking the palette as a parameter.
29 * It automatically creates the colormap for shading.
30 */
31Colormap::Colormap (const SDL_Color & pal, const SDL_PixelFormat & format) {
32 memcpy(palette, &pal, sizeof(palette));
33
34 assert(format.BytesPerPixel == 4);
35 colormap = malloc(format.BytesPerPixel * 65536);
36
37 for (int i = 0; i < 256; ++i)
38 for (int j = 0; j < 256; ++j) {
39 int32_t shade = (j < 128) ? j : (j - 256);
40 shade = 256 + 2 * shade;
41
42 const uint32_t r = std::min<uint32_t>((palette[i].r * shade) >> 8, 255);
43 const uint32_t g = std::min<uint32_t>((palette[i].g * shade) >> 8, 255);
44 const uint32_t b = std::min<uint32_t>((palette[i].b * shade) >> 8, 255);
45
46 const uint32_t value =
47 SDL_MapRGB(&const_cast<SDL_PixelFormat &>(format), r, g, b);
48 static_cast<uint32_t *>(colormap)[(j << 8) | i] = value;
49 }
50}
51
52/**
53 * Clean up.
54 */
55Colormap::~Colormap ()
56{
57 free(colormap);
58}
590
=== removed file 'src/graphic/colormap.h'
--- src/graphic/colormap.h 2014-07-12 12:25:21 +0000
+++ src/graphic/colormap.h 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1/*
2 * Copyright (C) 2002-2004, 2006, 2008 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#ifndef WL_GRAPHIC_COLORMAP_H
21#define WL_GRAPHIC_COLORMAP_H
22
23#include <SDL_video.h>
24
25#include "graphic/color.h"
26
27/**
28 * Colormap contains a palette and lookup table for use with ground textures.
29*/
30class Colormap {
31public:
32 Colormap (const SDL_Color &, const SDL_PixelFormat & fmt);
33 ~Colormap ();
34
35 // Returns the palette of this colormap (256 entries of RGB Colors);
36 SDL_Color * get_palette() {return palette;}
37
38 // Returns the internally calculated colormap used in the renderer.
39 void * get_colormap () const {return colormap;}
40
41private:
42 SDL_Color palette[256];
43
44 /// maps 8 bit color and brightness value to the shaded color.
45 /// \note Brightness is currently 8 bits. Restricting brightness to 64 or
46 /// less shades would greatly reduce the size of this table, and thus
47 /// improve memory cache impact inside the renderer.
48 void * colormap;
49};
50
51#endif // end of include guard: WL_GRAPHIC_COLORMAP_H
520
=== modified file 'src/graphic/game_renderer.cc'
--- src/graphic/game_renderer.cc 2014-09-27 18:53:55 +0000
+++ src/graphic/game_renderer.cc 2014-12-04 20:54:56 +0000
@@ -19,82 +19,227 @@
1919
20#include "graphic/game_renderer.h"20#include "graphic/game_renderer.h"
2121
22#include "base/macros.h"22#include <memory>
23
24#include "graphic/gl/dither_program.h"
25#include "graphic/gl/fields_to_draw.h"
26#include "graphic/gl/road_program.h"
27#include "graphic/gl/terrain_program.h"
23#include "graphic/graphic.h"28#include "graphic/graphic.h"
24#include "graphic/rendertarget.h"29#include "graphic/rendertarget.h"
30#include "graphic/surface.h"
25#include "logic/editor_game_base.h"31#include "logic/editor_game_base.h"
26#include "logic/player.h"32#include "logic/player.h"
33#include "logic/world/world.h"
34#include "wui/mapviewpixelconstants.h"
27#include "wui/mapviewpixelfunctions.h"35#include "wui/mapviewpixelfunctions.h"
28#include "wui/overlay_manager.h"36#include "wui/overlay_manager.h"
2937
38// Explanation of how drawing works:
39// Schematic of triangle neighborhood:
40//
41// *
42// / \
43// / u \
44// (f)/ \
45// *------*------* (r)
46// \ l / \ r / \
47// \ / \ / \
48// \/ d \/ rr \
49// *------*------* (br)
50// \ dd /
51// \ /
52// \/
53// *
54//
55// Each field (f) owns two triangles: (r)ight & (d)own. When we look at the
56// field, we have to make sure to schedule drawing the triangles. This is done
57// by of these triangles is done by TerrainProgram.
58//
59// To draw dithered edges, we have to look at the neighboring triangles for the
60// two triangles too: If a neighboring triangle has another texture and our
61// dither layer is smaller, we have to draw a dithering triangle too - this lets the neighboring
62// texture
63// bleed into our triangle.
64//
65// The dither triangle is the triangle that should be partially (either r or
66// d). Example: if r and d have different textures and r.dither_layer >
67// d.dither_layer, then we will repaint d with the dither texture as mask.
68
69std::unique_ptr<TerrainProgram> GameRenderer::terrain_program_;
70std::unique_ptr<DitherProgram> GameRenderer::dither_program_;
71std::unique_ptr<RoadProgram> GameRenderer::road_program_;
72
73namespace {
74
30using namespace Widelands;75using namespace Widelands;
3176
32GameRenderer::GameRenderer()77// Returns the brightness value in [0, 1.] for 'fcoords' at 'gametime' for
33{78// 'player' (which can be nullptr).
34}79float field_brightness(const FCoords& fcoords,
3580 const uint32_t gametime,
36GameRenderer::~GameRenderer()81 const Map& map,
37{82 const Player* const player) {
38}83 uint32_t brightness = 144 + fcoords.field->get_brightness();
3984 brightness = std::min<uint32_t>(255, (brightness * 255) / 160);
40void GameRenderer::rendermap85
41 (RenderTarget & dst,86 if (player && !player->see_all()) {
42 const Widelands::EditorGameBase & egbase,87 const Player::Field& pf = player->fields()[Map::get_index(fcoords, map.get_width())];
43 const Widelands::Player & player,88 if (pf.vision == 0) {
44 const Point & viewofs)89 return 0.;
45{90 } else if (pf.vision == 1) {
46 m_dst = &dst;91 static const uint32_t kDecayTimeInMs = 20000;
47 m_dst_offset = -viewofs;92 const Duration time_ago = gametime - pf.time_node_last_unseen;
48 m_egbase = &egbase;93 if (time_ago < kDecayTimeInMs) {
49 m_player = &player;94 brightness = (brightness * (2 * kDecayTimeInMs - time_ago)) / (2 * kDecayTimeInMs);
5095 } else {
51 draw_wrapper();96 brightness = brightness / 2;
52}97 }
5398 }
54void GameRenderer::rendermap99 }
55 (RenderTarget & dst,100 return brightness / 255.;
56 const Widelands::EditorGameBase & egbase,101}
57 const Point & viewofs)102
58{103// Returns the road that should be rendered here. The format is like in field,
59 m_dst = &dst;104// but this is not the physically present road, but the one that should be
60 m_dst_offset = -viewofs;105// drawn (i.e. taking into account if there is fog of war involved or road
61 m_egbase = &egbase;106// building overlays enabled).
62 m_player = nullptr;107uint8_t field_roads(const FCoords& coords, const Map& map, const Player* const player) {
63108 uint8_t roads;
64 draw_wrapper();109 if (player && !player->see_all()) {
65}110 const Player::Field& pf = player->fields()[Map::get_index(coords, map.get_width())];
66111 roads = pf.roads | map.overlay_manager().get_road_overlay(coords);
67void GameRenderer::draw_wrapper()112 } else {
68{113 roads = coords.field->get_roads();
69 Point tl_map = m_dst->get_offset() - m_dst_offset;114 }
115 roads |= map.overlay_manager().get_road_overlay(coords);
116 return roads;
117}
118
119} // namespace
120
121GameRenderer::GameRenderer() {
122}
123
124GameRenderer::~GameRenderer() {
125}
126
127void GameRenderer::rendermap(RenderTarget& dst,
128 const Widelands::EditorGameBase& egbase,
129 const Point& view_offset,
130
131 const Widelands::Player& player) {
132 draw(dst, egbase, view_offset, &player);
133}
134
135void GameRenderer::rendermap(RenderTarget& dst,
136 const Widelands::EditorGameBase& egbase,
137 const Point& view_offset) {
138 draw(dst, egbase, view_offset, nullptr);
139}
140
141void GameRenderer::draw(RenderTarget& dst,
142 const EditorGameBase& egbase,
143 const Point& view_offset,
144 const Player* player) {
145 if (terrain_program_ == nullptr) {
146 terrain_program_.reset(new TerrainProgram());
147 dither_program_.reset(new DitherProgram());
148 road_program_.reset(new RoadProgram());
149 }
150
151 Point tl_map = dst.get_offset() + view_offset;
70152
71 assert(tl_map.x >= 0); // divisions involving negative numbers are bad153 assert(tl_map.x >= 0); // divisions involving negative numbers are bad
72 assert(tl_map.y >= 0);154 assert(tl_map.y >= 0);
73155
74 m_minfx = tl_map.x / TRIANGLE_WIDTH - 1;156 int minfx = tl_map.x / TRIANGLE_WIDTH - 1;
75 m_minfy = tl_map.y / TRIANGLE_HEIGHT - 1;157 int minfy = tl_map.y / TRIANGLE_HEIGHT - 1;
76 m_maxfx = (tl_map.x + m_dst->get_rect().w + (TRIANGLE_WIDTH / 2)) / TRIANGLE_WIDTH;158 int maxfx = (tl_map.x + dst.get_rect().w + (TRIANGLE_WIDTH / 2)) / TRIANGLE_WIDTH;
77 m_maxfy = (tl_map.y + m_dst->get_rect().h) / TRIANGLE_HEIGHT;159 int maxfy = (tl_map.y + dst.get_rect().h) / TRIANGLE_HEIGHT;
78160
79 // fudge for triangle boundary effects and for height differences161 // fudge for triangle boundary effects and for height differences
80 m_minfx -= 1;162 minfx -= 1;
81 m_minfy -= 1;163 minfy -= 1;
82 m_maxfx += 1;164 maxfx += 1;
83 m_maxfy += 10;165 maxfy += 10;
84166
85 draw();167
168 Surface* surface = dst.get_surface();
169 if (!surface)
170 return;
171
172 const Rect& bounding_rect = dst.get_rect();
173 const Point surface_offset = bounding_rect.top_left() + dst.get_offset() - view_offset;
174
175 glScissor(bounding_rect.x,
176 surface->height() - bounding_rect.y - bounding_rect.h,
177 bounding_rect.w,
178 bounding_rect.h);
179 glEnable(GL_SCISSOR_TEST);
180
181 Map& map = egbase.map();
182 const uint32_t gametime = egbase.get_gametime();
183
184 FieldsToDraw fields_to_draw(minfx, maxfx, minfy, maxfy);
185 for (int32_t fy = minfy; fy <= maxfy; ++fy) {
186 for (int32_t fx = minfx; fx <= maxfx; ++fx) {
187 FieldsToDraw::Field& f =
188 *fields_to_draw.mutable_field(fields_to_draw.calculate_index(fx, fy));
189
190 f.fx = fx;
191 f.fy = fy;
192
193 Coords coords(fx, fy);
194 int x, y;
195 MapviewPixelFunctions::get_basepix(coords, x, y);
196
197 map.normalize_coords(coords);
198 const FCoords& fcoords = map.get_fcoords(coords);
199
200 f.texture_x = float(x) / kTextureSideLength;
201 f.texture_y = float(y) / kTextureSideLength;
202
203 f.gl_x = f.pixel_x = x + surface_offset.x;
204 f.gl_y = f.pixel_y = y + surface_offset.y - fcoords.field->get_height() * HEIGHT_FACTOR;
205 surface->pixel_to_gl(&f.gl_x, &f.gl_y);
206
207 f.ter_d = fcoords.field->terrain_d();
208 f.ter_r = fcoords.field->terrain_r();
209
210 f.brightness = field_brightness(fcoords, gametime, map, player);
211
212 f.roads = field_roads(fcoords, map, player);
213 }
214 }
215
216 const World& world = egbase.world();
217 terrain_program_->draw(gametime, world.terrains(), fields_to_draw);
218 dither_program_->draw(gametime, world.terrains(), fields_to_draw);
219 road_program_->draw(*surface, fields_to_draw);
220
221 draw_objects(dst, egbase, view_offset, player, minfx, maxfx, minfy, maxfy);
222
223 glDisable(GL_SCISSOR_TEST);
86}224}
87225
88void GameRenderer::draw_objects()226void GameRenderer::draw_objects(RenderTarget& dst,
89{227 const EditorGameBase& egbase,
228 const Point& view_offset,
229 const Player* player,
230 int minfx,
231 int maxfx,
232 int minfy,
233 int maxfy) {
234 // TODO(sirver): this should use FieldsToDraw. Would simplify this function a lot.
90 static const uint32_t F = 0;235 static const uint32_t F = 0;
91 static const uint32_t R = 1;236 static const uint32_t R = 1;
92 static const uint32_t BL = 2;237 static const uint32_t BL = 2;
93 static const uint32_t BR = 3;238 static const uint32_t BR = 3;
94 const Map & map = m_egbase->map();239 const Map & map = egbase.map();
95240
96 for (int32_t fy = m_minfy; fy <= m_maxfy; ++fy) {241 for (int32_t fy = minfy; fy <= maxfy; ++fy) {
97 for (int32_t fx = m_minfx; fx <= m_maxfx; ++fx) {242 for (int32_t fx = minfx; fx <= maxfx; ++fx) {
98 Coords ncoords(fx, fy);243 Coords ncoords(fx, fy);
99 map.normalize_coords(ncoords);244 map.normalize_coords(ncoords);
100 FCoords coords[4];245 FCoords coords[4];
@@ -109,7 +254,7 @@
109 MapviewPixelFunctions::get_basepix(Coords(fx + (fy & 1), fy + 1), pos[BR].x, pos[BR].y);254 MapviewPixelFunctions::get_basepix(Coords(fx + (fy & 1), fy + 1), pos[BR].x, pos[BR].y);
110 for (uint32_t d = 0; d < 4; ++d) {255 for (uint32_t d = 0; d < 4; ++d) {
111 pos[d].y -= coords[d].field->get_height() * HEIGHT_FACTOR;256 pos[d].y -= coords[d].field->get_height() * HEIGHT_FACTOR;
112 pos[d] += m_dst_offset;257 pos[d] -= view_offset;
113 }258 }
114259
115 PlayerNumber owner_number[4];260 PlayerNumber owner_number[4];
@@ -120,9 +265,9 @@
120 for (uint32_t d = 0; d < 4; ++d)265 for (uint32_t d = 0; d < 4; ++d)
121 isborder[d] = coords[d].field->is_border();266 isborder[d] = coords[d].field->is_border();
122267
123 if (m_player && !m_player->see_all()) {268 if (player && !player->see_all()) {
124 for (uint32_t d = 0; d < 4; ++d) {269 for (uint32_t d = 0; d < 4; ++d) {
125 const Player::Field & pf = m_player->fields()[map.get_index(coords[d], map.get_width())];270 const Player::Field & pf = player->fields()[map.get_index(coords[d], map.get_width())];
126 vision[d] = pf.vision;271 vision[d] = pf.vision;
127 if (pf.vision == 1) {272 if (pf.vision == 1) {
128 owner_number[d] = pf.owner;273 owner_number[d] = pf.owner;
@@ -132,32 +277,32 @@
132 }277 }
133278
134 if (isborder[F]) {279 if (isborder[F]) {
135 const Player & owner = m_egbase->player(owner_number[F]);280 const Player & owner = egbase.player(owner_number[F]);
136 uint32_t const anim_idx = owner.tribe().frontier_animation();281 uint32_t const anim_idx = owner.tribe().frontier_animation();
137 if (vision[F])282 if (vision[F])
138 m_dst->drawanim(pos[F], anim_idx, 0, &owner);283 dst.drawanim(pos[F], anim_idx, 0, &owner);
139 for (uint32_t d = 1; d < 4; ++d) {284 for (uint32_t d = 1; d < 4; ++d) {
140 if285 if
141 ((vision[F] || vision[d]) &&286 ((vision[F] || vision[d]) &&
142 isborder[d] &&287 isborder[d] &&
143 (owner_number[d] == owner_number[F] || !owner_number[d]))288 (owner_number[d] == owner_number[F] || !owner_number[d]))
144 {289 {
145 m_dst->drawanim(middle(pos[F], pos[d]), anim_idx, 0, &owner);290 dst.drawanim(middle(pos[F], pos[d]), anim_idx, 0, &owner);
146 }291 }
147 }292 }
148 }293 }
149294
150 if (1 < vision[F]) { // Render stuff that belongs to the node.295 if (1 < vision[F]) { // Render stuff that belongs to the node.
151 if (BaseImmovable * const imm = coords[F].field->get_immovable())296 if (BaseImmovable * const imm = coords[F].field->get_immovable())
152 imm->draw(*m_egbase, *m_dst, coords[F], pos[F]);297 imm->draw(egbase, dst, coords[F], pos[F]);
153 for298 for
154 (Bob * bob = coords[F].field->get_first_bob();299 (Bob * bob = coords[F].field->get_first_bob();
155 bob;300 bob;
156 bob = bob->get_next_bob())301 bob = bob->get_next_bob())
157 bob->draw(*m_egbase, *m_dst, pos[F]);302 bob->draw(egbase, dst, pos[F]);
158 } else if (vision[F] == 1) {303 } else if (vision[F] == 1) {
159 const Player::Field & f_pl = m_player->fields()[map.get_index(coords[F], map.get_width())];304 const Player::Field & f_pl = player->fields()[map.get_index(coords[F], map.get_width())];
160 const Player * owner = owner_number[F] ? m_egbase->get_player(owner_number[F]) : nullptr;305 const Player * owner = owner_number[F] ? egbase.get_player(owner_number[F]) : nullptr;
161 if306 if
162 (const MapObjectDescr * const map_object_descr =307 (const MapObjectDescr * const map_object_descr =
163 f_pl.map_object_descr[TCoords<>::None])308 f_pl.map_object_descr[TCoords<>::None])
@@ -193,7 +338,7 @@
193338
194 if (cur_frame) // not the first frame339 if (cur_frame) // not the first frame
195 // draw the prev frame from top to where next image will be drawing340 // draw the prev frame from top to where next image will be drawing
196 m_dst->drawanimrect341 dst.drawanimrect
197 (pos[F], anim_idx, tanim - FRAME_LENGTH, owner, Rect(Point(0, 0), w, h - lines));342 (pos[F], anim_idx, tanim - FRAME_LENGTH, owner, Rect(Point(0, 0), w, h - lines));
198 else if (csinf.was) {343 else if (csinf.was) {
199 // Is the first frame, but there was another building here before,344 // Is the first frame, but there was another building here before,
@@ -204,11 +349,11 @@
204 } catch (MapObjectDescr::AnimationNonexistent &) {349 } catch (MapObjectDescr::AnimationNonexistent &) {
205 a = csinf.was->get_animation("idle");350 a = csinf.was->get_animation("idle");
206 }351 }
207 m_dst->drawanimrect352 dst.drawanimrect
208 (pos[F], a, tanim - FRAME_LENGTH, owner, Rect(Point(0, 0), w, h - lines));353 (pos[F], a, tanim - FRAME_LENGTH, owner, Rect(Point(0, 0), w, h - lines));
209 }354 }
210 assert(lines <= h);355 assert(lines <= h);
211 m_dst->drawanimrect(pos[F], anim_idx, tanim, owner, Rect(Point(0, h - lines), w, lines));356 dst.drawanimrect(pos[F], anim_idx, tanim, owner, Rect(Point(0, h - lines), w, lines));
212 } else if (upcast(const BuildingDescr, building, map_object_descr)) {357 } else if (upcast(const BuildingDescr, building, map_object_descr)) {
213 // this is a building therefore we either draw unoccupied or idle animation358 // this is a building therefore we either draw unoccupied or idle animation
214 uint32_t pic;359 uint32_t pic;
@@ -217,11 +362,11 @@
217 } catch (MapObjectDescr::AnimationNonexistent &) {362 } catch (MapObjectDescr::AnimationNonexistent &) {
218 pic = building->get_animation("idle");363 pic = building->get_animation("idle");
219 }364 }
220 m_dst->drawanim(pos[F], pic, 0, owner);365 dst.drawanim(pos[F], pic, 0, owner);
221 } else if (const uint32_t pic = map_object_descr->main_animation()) {366 } else if (const uint32_t pic = map_object_descr->main_animation()) {
222 m_dst->drawanim(pos[F], pic, 0, owner);367 dst.drawanim(pos[F], pic, 0, owner);
223 } else if (map_object_descr->type() == MapObjectType::FLAG) {368 } else if (map_object_descr->type() == MapObjectType::FLAG) {
224 m_dst->drawanim(pos[F], owner->tribe().flag_animation(), 0, owner);369 dst.drawanim(pos[F], owner->tribe().flag_animation(), 0, owner);
225 }370 }
226 }371 }
227 }372 }
@@ -239,7 +384,7 @@
239 (const OverlayManager::OverlayInfo * it = overlay_info;384 (const OverlayManager::OverlayInfo * it = overlay_info;
240 it < end;385 it < end;
241 ++it)386 ++it)
242 m_dst->blit(pos[F] - it->hotspot, it->pic);387 dst.blit(pos[F] - it->hotspot, it->pic);
243 }388 }
244389
245 {390 {
@@ -259,7 +404,7 @@
259 (OverlayManager::OverlayInfo const * it = overlay_info;404 (OverlayManager::OverlayInfo const * it = overlay_info;
260 it < end;405 it < end;
261 ++it)406 ++it)
262 m_dst->blit(tripos - it->hotspot, it->pic);407 dst.blit(tripos - it->hotspot, it->pic);
263 }408 }
264409
265 {410 {
@@ -279,7 +424,7 @@
279 (OverlayManager::OverlayInfo const * it = overlay_info;424 (OverlayManager::OverlayInfo const * it = overlay_info;
280 it < end;425 it < end;
281 ++it)426 ++it)
282 m_dst->blit(tripos - it->hotspot, it->pic);427 dst.blit(tripos - it->hotspot, it->pic);
283 }428 }
284 }429 }
285 }430 }
286431
=== modified file 'src/graphic/game_renderer.h'
--- src/graphic/game_renderer.h 2014-09-27 18:53:55 +0000
+++ src/graphic/game_renderer.h 2014-12-04 20:54:56 +0000
@@ -20,17 +20,22 @@
20#ifndef WL_GRAPHIC_GAME_RENDERER_H20#ifndef WL_GRAPHIC_GAME_RENDERER_H
21#define WL_GRAPHIC_GAME_RENDERER_H21#define WL_GRAPHIC_GAME_RENDERER_H
2222
23#include <boost/utility.hpp>23#include <memory>
2424
25#include "base/macros.h"25#include "base/macros.h"
26#include "base/point.h"26#include "base/point.h"
27#include "graphic/gl/utils.h"
2728
28namespace Widelands {29namespace Widelands {
29 class Player;30 class Player;
30 class EditorGameBase;31 class EditorGameBase;
31}32}
3233
34class DitherProgram;
33class RenderTarget;35class RenderTarget;
36class RoadProgram;
37class TerrainProgram;
38
3439
35/**40/**
36 * This abstract base class renders the main game view into an41 * This abstract base class renders the main game view into an
@@ -45,56 +50,41 @@
45class GameRenderer {50class GameRenderer {
46public:51public:
47 GameRenderer();52 GameRenderer();
48 virtual ~GameRenderer();53 ~GameRenderer();
4954
50 /**55 // Renders the map from a player's point of view into the given
51 * Renders the map from a player's point of view into the56 // drawing window. 'view_offset' is the offset of the upper left
52 * given drawing window.57 // corner of the window into the map, in pixels.
53 *58 void rendermap(RenderTarget& dst,
54 * @param viewofs is the offset of the upper left corner of59 const Widelands::EditorGameBase& egbase,
55 * the window into the map, in pixels.60 const Point& view_offset,
56 */61 const Widelands::Player& player);
57 void rendermap62
58 (RenderTarget & dst,63 // Renders the map from an omniscient perspective. This is used
59 const Widelands::EditorGameBase & egbase,64 // for spectators, players that see all, and in the editor.
60 const Widelands::Player & player,65 void rendermap(RenderTarget& dst, const Widelands::EditorGameBase& egbase, const Point& view_offset);
61 const Point & viewofs);
62
63 /**
64 * Renders the map from an omniscient perspective.
65 * This is used for spectators, players that see all, and in the editor.
66 */
67 void rendermap
68 (RenderTarget & dst,
69 const Widelands::EditorGameBase & egbase,
70 const Point & viewofs);
71
72protected:
73 virtual void draw() = 0;
74
75 void draw_objects();
76
77 /**
78 * The following variables, which are setup by @ref rendermap,
79 * are only valid during rendering,
80 * and should be treated as read-only by derived classes.
81 */
82 /*@{*/
83 RenderTarget * m_dst;
84 Widelands::EditorGameBase const * m_egbase;
85 Widelands::Player const * m_player;
86
87 /// Translation from map pixel coordinates to @ref m_dst pixel coordinates
88 Point m_dst_offset;
89
90 int32_t m_minfx;
91 int32_t m_minfy;
92 int32_t m_maxfx;
93 int32_t m_maxfy;
94 /*@}*/
9566
96private:67private:
97 void draw_wrapper();68 static std::unique_ptr<TerrainProgram> terrain_program_;
69 static std::unique_ptr<DitherProgram> dither_program_;
70 static std::unique_ptr<RoadProgram> road_program_;
71
72 // Draw the map for the given parameters (see rendermap). 'player'
73 // can be nullptr in which case the whole map is drawn.
74 void draw(RenderTarget& dst,
75 const Widelands::EditorGameBase& egbase,
76 const Point& view_offset,
77 const Widelands::Player* player);
78
79 // Draws the objects (animations & overlays).
80 void draw_objects(RenderTarget& dst,
81 const Widelands::EditorGameBase& egbase,
82 const Point& view_offset,
83 const Widelands::Player* player,
84 int minfx,
85 int maxfx,
86 int minfy,
87 int maxfy);
9888
99 DISALLOW_COPY_AND_ASSIGN(GameRenderer);89 DISALLOW_COPY_AND_ASSIGN(GameRenderer);
100};90};
10191
=== removed file 'src/graphic/gl/game_renderer.cc'
--- src/graphic/gl/game_renderer.cc 2014-11-28 05:40:53 +0000
+++ src/graphic/gl/game_renderer.cc 1970-01-01 00:00:00 +0000
@@ -1,191 +0,0 @@
1/*
2 * Copyright (C) 2011-2013 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include "graphic/gl/game_renderer.h"
21
22#include <memory>
23
24#include "graphic/gl/dither_program.h"
25#include "graphic/gl/fields_to_draw.h"
26#include "graphic/gl/road_program.h"
27#include "graphic/gl/terrain_program.h"
28#include "graphic/graphic.h"
29#include "graphic/rendertarget.h"
30#include "graphic/surface.h"
31#include "logic/editor_game_base.h"
32#include "logic/player.h"
33#include "logic/world/world.h"
34#include "wui/mapviewpixelconstants.h"
35#include "wui/mapviewpixelfunctions.h"
36#include "wui/overlay_manager.h"
37
38namespace {
39
40using namespace Widelands;
41
42// Returns the brightness value in [0, 1.] for 'fcoords' at 'gametime' for
43// 'player' (which can be nullptr).
44float field_brightness(const FCoords& fcoords,
45 const uint32_t gametime,
46 const Map& map,
47 const Player* const player) {
48 uint32_t brightness = 144 + fcoords.field->get_brightness();
49 brightness = std::min<uint32_t>(255, (brightness * 255) / 160);
50
51 if (player && !player->see_all()) {
52 const Player::Field& pf = player->fields()[Map::get_index(fcoords, map.get_width())];
53 if (pf.vision == 0) {
54 return 0.;
55 } else if (pf.vision == 1) {
56 static const uint32_t kDecayTimeInMs = 20000;
57 const Duration time_ago = gametime - pf.time_node_last_unseen;
58 if (time_ago < kDecayTimeInMs) {
59 brightness = (brightness * (2 * kDecayTimeInMs - time_ago)) / (2 * kDecayTimeInMs);
60 } else {
61 brightness = brightness / 2;
62 }
63 }
64 }
65 return brightness / 255.;
66}
67
68// Returns the road that should be rendered here. The format is like in field,
69// but this is not the physically present road, but the one that should be
70// drawn (i.e. taking into account if there is fog of war involved or road
71// building overlays enabled).
72uint8_t field_roads(const FCoords& coords, const Map& map, const Player* const player) {
73 uint8_t roads;
74 if (player && !player->see_all()) {
75 const Player::Field& pf = player->fields()[Map::get_index(coords, map.get_width())];
76 roads = pf.roads | map.overlay_manager().get_road_overlay(coords);
77 } else {
78 roads = coords.field->get_roads();
79 }
80 roads |= map.overlay_manager().get_road_overlay(coords);
81 return roads;
82}
83
84} // namespace
85
86// Explanation of how drawing works:
87// Schematic of triangle neighborhood:
88//
89// *
90// / \
91// / u \
92// (f)/ \
93// *------*------* (r)
94// \ l / \ r / \
95// \ / \ / \
96// \/ d \/ rr \
97// *------*------* (br)
98// \ dd /
99// \ /
100// \/
101// *
102//
103// Each field (f) owns two triangles: (r)ight & (d)own. When we look at the
104// field, we have to make sure to schedule drawing the triangles. This is done
105// by of these triangles is done by TerrainProgram.
106//
107// To draw dithered edges, we have to look at the neighboring triangles for the
108// two triangles too: If a neighboring triangle has another texture and our
109// dither layer is smaller, we have to draw a dithering triangle too - this lets the neighboring
110// texture
111// bleed into our triangle.
112//
113// The dither triangle is the triangle that should be partially (either r or
114// d). Example: if r and d have different textures and r.dither_layer >
115// d.dither_layer, then we will repaint d with the dither texture as mask.
116
117
118std::unique_ptr<TerrainProgram> GlGameRenderer::terrain_program_;
119std::unique_ptr<DitherProgram> GlGameRenderer::dither_program_;
120std::unique_ptr<RoadProgram> GlGameRenderer::road_program_;
121
122GlGameRenderer::GlGameRenderer() {
123}
124
125GlGameRenderer::~GlGameRenderer() {
126}
127
128void GlGameRenderer::draw() {
129 if (terrain_program_ == nullptr) {
130 terrain_program_.reset(new TerrainProgram());
131 dither_program_.reset(new DitherProgram());
132 road_program_.reset(new RoadProgram());
133 }
134
135 Surface* surface = m_dst->get_surface();
136 if (!surface)
137 return;
138
139 const Rect& bounding_rect = m_dst->get_rect();
140 const Point surface_offset = m_dst_offset + bounding_rect.top_left() + m_dst->get_offset();
141
142 glScissor(bounding_rect.x,
143 surface->height() - bounding_rect.y - bounding_rect.h,
144 bounding_rect.w,
145 bounding_rect.h);
146 glEnable(GL_SCISSOR_TEST);
147
148 Map& map = m_egbase->map();
149 const uint32_t gametime = m_egbase->get_gametime();
150
151 FieldsToDraw fields_to_draw(m_minfx, m_maxfx, m_minfy, m_maxfy);
152 for (int32_t fy = m_minfy; fy <= m_maxfy; ++fy) {
153 for (int32_t fx = m_minfx; fx <= m_maxfx; ++fx) {
154 FieldsToDraw::Field& f =
155 *fields_to_draw.mutable_field(fields_to_draw.calculate_index(fx, fy));
156
157 f.fx = fx;
158 f.fy = fy;
159
160 Coords coords(fx, fy);
161 int x, y;
162 MapviewPixelFunctions::get_basepix(coords, x, y);
163
164 map.normalize_coords(coords);
165 const FCoords& fcoords = map.get_fcoords(coords);
166
167 f.texture_x = float(x) / kTextureSideLength;
168 f.texture_y = float(y) / kTextureSideLength;
169
170 f.gl_x = f.pixel_x = x + surface_offset.x;
171 f.gl_y = f.pixel_y = y + surface_offset.y - fcoords.field->get_height() * HEIGHT_FACTOR;
172 surface->pixel_to_gl(&f.gl_x, &f.gl_y);
173
174 f.ter_d = fcoords.field->terrain_d();
175 f.ter_r = fcoords.field->terrain_r();
176
177 f.brightness = field_brightness(fcoords, gametime, map, m_player);
178
179 f.roads = field_roads(fcoords, map, m_player);
180 }
181 }
182
183 const World& world = m_egbase->world();
184 terrain_program_->draw(gametime, world.terrains(), fields_to_draw);
185 dither_program_->draw(gametime, world.terrains(), fields_to_draw);
186 road_program_->draw(*surface, fields_to_draw);
187
188 draw_objects();
189
190 glDisable(GL_SCISSOR_TEST);
191}
1920
=== removed file 'src/graphic/gl/game_renderer.h'
--- src/graphic/gl/game_renderer.h 2014-11-01 20:40:39 +0000
+++ src/graphic/gl/game_renderer.h 1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
1/*
2 * Copyright (C) 2011-2013 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#ifndef WL_GRAPHIC_GL_GAME_RENDERER_H
21#define WL_GRAPHIC_GL_GAME_RENDERER_H
22
23#include <memory>
24
25#include "graphic/game_renderer.h"
26#include "graphic/gl/utils.h"
27
28class TerrainProgram;
29class DitherProgram;
30class RoadProgram;
31
32/**
33 * OpenGL implementation of @ref GameRenderer.
34 */
35class GlGameRenderer : public GameRenderer {
36public:
37 GlGameRenderer();
38 virtual ~GlGameRenderer();
39
40private:
41 static std::unique_ptr<TerrainProgram> terrain_program_;
42 static std::unique_ptr<DitherProgram> dither_program_;
43 static std::unique_ptr<RoadProgram> road_program_;
44
45 void draw() override;
46};
47
48#endif // end of include guard: WL_GRAPHIC_GL_GAME_RENDERER_H
490
=== modified file 'src/graphic/rendertarget.cc'
--- src/graphic/rendertarget.cc 2014-12-02 19:00:52 +0000
+++ src/graphic/rendertarget.cc 2014-12-04 20:54:56 +0000
@@ -27,7 +27,6 @@
27#include "graphic/surface.h"27#include "graphic/surface.h"
28#include "logic/player.h"28#include "logic/player.h"
29#include "logic/tribe.h"29#include "logic/tribe.h"
30#include "wui/mapviewpixelconstants.h"
31#include "wui/overlay_manager.h"30#include "wui/overlay_manager.h"
3231
33using Widelands::BaseImmovable;32using Widelands::BaseImmovable;
3433
=== modified file 'src/logic/CMakeLists.txt'
--- src/logic/CMakeLists.txt 2014-12-01 21:28:21 +0000
+++ src/logic/CMakeLists.txt 2014-12-04 20:54:56 +0000
@@ -6,6 +6,7 @@
6 base_log6 base_log
7 graphic7 graphic
8 graphic_image_io8 graphic_image_io
9 graphic_minimap_renderer
9 graphic_surface10 graphic_surface
10 io_fileread11 io_fileread
11 io_filesystem12 io_filesystem
@@ -250,5 +251,7 @@
250 ui_basic251 ui_basic
251 widelands_ball_of_mud252 widelands_ball_of_mud
252 wui253 wui
254 wui_mapview_pixelfunctions
255 wui_overlay_manager
253 wui_text_layout256 wui_text_layout
254)257)
255258
=== modified file 'src/map_io/CMakeLists.txt'
--- src/map_io/CMakeLists.txt 2014-12-01 21:31:00 +0000
+++ src/map_io/CMakeLists.txt 2014-12-04 20:54:56 +0000
@@ -93,6 +93,7 @@
93 economy93 economy
94 graphic94 graphic
95 graphic_image_io95 graphic_image_io
96 graphic_minimap_renderer
96 graphic_surface97 graphic_surface
97 helper98 helper
98 io_fileread99 io_fileread
99100
=== modified file 'src/scripting/CMakeLists.txt'
--- src/scripting/CMakeLists.txt 2014-11-28 16:40:55 +0000
+++ src/scripting/CMakeLists.txt 2014-12-04 20:54:56 +0000
@@ -57,4 +57,5 @@
57 third_party_eris57 third_party_eris
58 ui_basic58 ui_basic
59 wui59 wui
60 wui_mapview_pixelfunctions
60)61)
6162
=== modified file 'src/sound/CMakeLists.txt'
--- src/sound/CMakeLists.txt 2014-11-28 16:40:55 +0000
+++ src/sound/CMakeLists.txt 2014-12-04 20:54:56 +0000
@@ -21,4 +21,5 @@
21 profile21 profile
22 random22 random
23 wui23 wui
24 wui_mapview_pixelfunctions
24)25)
2526
=== modified file 'src/wui/CMakeLists.txt'
--- src/wui/CMakeLists.txt 2014-11-28 16:40:55 +0000
+++ src/wui/CMakeLists.txt 2014-12-04 20:54:56 +0000
@@ -29,6 +29,29 @@
29 wui29 wui
30)30)
3131
32wl_library(wui_overlay_manager
33 SRCS
34 overlay_manager.cc
35 overlay_manager.h
36 DEPENDS
37 base_geometry
38 graphic
39 logic
40 logic_widelands_geometry
41)
42
43wl_library(wui_mapview_pixelfunctions
44 SRCS
45 mapviewpixelconstants.h
46 mapviewpixelfunctions.cc
47 mapviewpixelfunctions.h
48 vector.h
49 DEPENDS
50 base_geometry
51 logic
52 logic_widelands_geometry
53)
54
32wl_library(wui55wl_library(wui
33 SRCS56 SRCS
34 actionconfirm.cc57 actionconfirm.cc
@@ -83,16 +106,11 @@
83 logmessage.h106 logmessage.h
84 mapview.cc107 mapview.cc
85 mapview.h108 mapview.h
86 mapviewpixelconstants.h
87 mapviewpixelfunctions.cc
88 mapviewpixelfunctions.h
89 militarysitewindow.cc109 militarysitewindow.cc
90 minimap.cc110 minimap.cc
91 minimap.h111 minimap.h
92 multiplayersetupgroup.cc112 multiplayersetupgroup.cc
93 multiplayersetupgroup.h113 multiplayersetupgroup.h
94 overlay_manager.cc
95 overlay_manager.h
96 playerdescrgroup.cc114 playerdescrgroup.cc
97 playerdescrgroup.h115 playerdescrgroup.h
98 plot_area.cc116 plot_area.cc
@@ -117,7 +135,6 @@
117 transport_ui.cc135 transport_ui.cc
118 unique_window_handler.cc136 unique_window_handler.cc
119 unique_window_handler.h137 unique_window_handler.h
120 vector.h
121 ware_statistics_menu.cc138 ware_statistics_menu.cc
122 ware_statistics_menu.h139 ware_statistics_menu.h
123 warehousewindow.cc140 warehousewindow.cc
@@ -140,7 +157,9 @@
140 game_io157 game_io
141 graphic158 graphic
142 graphic_color159 graphic_color
160 graphic_game_renderer
143 graphic_image161 graphic_image
162 graphic_minimap_renderer
144 graphic_surface163 graphic_surface
145 io_fileread164 io_fileread
146 io_filesystem165 io_filesystem
@@ -157,5 +176,7 @@
157 ui_fsmenu176 ui_fsmenu
158 widelands_ball_of_mud177 widelands_ball_of_mud
159 wui_chat_ui178 wui_chat_ui
179 wui_mapview_pixelfunctions
180 wui_overlay_manager
160 wui_text_layout181 wui_text_layout
161)182)
162183
=== modified file 'src/wui/mapview.cc'
--- src/wui/mapview.cc 2014-11-22 18:36:33 +0000
+++ src/wui/mapview.cc 2014-12-04 20:54:56 +0000
@@ -20,7 +20,7 @@
20#include "wui/mapview.h"20#include "wui/mapview.h"
2121
22#include "base/macros.h"22#include "base/macros.h"
23#include "graphic/gl/game_renderer.h"23#include "graphic/game_renderer.h"
24#include "graphic/graphic.h"24#include "graphic/graphic.h"
25#include "graphic/rendertarget.h"25#include "graphic/rendertarget.h"
26#include "logic/map.h"26#include "logic/map.h"
@@ -31,16 +31,14 @@
31#include "wui/mapviewpixelfunctions.h"31#include "wui/mapviewpixelfunctions.h"
32#include "wui/overlay_manager.h"32#include "wui/overlay_manager.h"
3333
34MapView::MapView34MapView::MapView(
35 (UI::Panel * parent,35 UI::Panel* parent, int32_t x, int32_t y, uint32_t w, uint32_t h, InteractiveBase& player)
36 int32_t x, int32_t y, uint32_t w, uint32_t h,36 : UI::Panel(parent, x, y, w, h),
37 InteractiveBase & player)37 m_renderer(new GameRenderer()),
38:38 m_intbase(player),
39UI::Panel (parent, x, y, w, h),39 m_viewpoint(Point(0, 0)),
40m_intbase (player),40 m_dragging(false) {
41m_viewpoint (Point(0, 0)),41}
42m_dragging (false)
43{}
4442
45MapView::~MapView()43MapView::~MapView()
46{44{
@@ -90,11 +88,8 @@
9088
91 egbase.map().overlay_manager().load_graphics();89 egbase.map().overlay_manager().load_graphics();
9290
93 if (!m_renderer) {
94 m_renderer.reset(new GlGameRenderer());
95 }
96 if (upcast(InteractivePlayer const, interactive_player, &intbase())) {91 if (upcast(InteractivePlayer const, interactive_player, &intbase())) {
97 m_renderer->rendermap(dst, egbase, interactive_player->player(), m_viewpoint);92 m_renderer->rendermap(dst, egbase, m_viewpoint, interactive_player->player());
98 } else {93 } else {
99 m_renderer->rendermap(dst, egbase, m_viewpoint);94 m_renderer->rendermap(dst, egbase, m_viewpoint);
100 }95 }

Subscribers

People subscribed via source and target branches

to status/vote changes: