Merge lp:~widelands-dev/widelands/cleanup_game_renderer into lp:widelands
- cleanup_game_renderer
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
GunChleoc | Approve | ||
Review via email: mp+243124@code.launchpad.net |
Commit message
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?
GunChleoc (gunchleoc) wrote : | # |
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/
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?
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.
GunChleoc (gunchleoc) wrote : | # |
Fixed 2 nits myself + tested. LGTM.
I love these graphic changes, Widelands is now noticeably faster on my machine.
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
1 | === modified file 'src/editor/CMakeLists.txt' | |||
2 | --- src/editor/CMakeLists.txt 2014-10-13 15:04:50 +0000 | |||
3 | +++ src/editor/CMakeLists.txt 2014-12-04 20:54:56 +0000 | |||
4 | @@ -104,4 +104,6 @@ | |||
5 | 104 | ui_fsmenu | 104 | ui_fsmenu |
6 | 105 | widelands_ball_of_mud | 105 | widelands_ball_of_mud |
7 | 106 | wui | 106 | wui |
8 | 107 | wui_mapview_pixelfunctions | ||
9 | 108 | wui_overlay_manager | ||
10 | 107 | ) | 109 | ) |
11 | 108 | 110 | ||
12 | === modified file 'src/game_io/CMakeLists.txt' | |||
13 | --- src/game_io/CMakeLists.txt 2014-11-24 06:31:16 +0000 | |||
14 | +++ src/game_io/CMakeLists.txt 2014-12-04 20:54:56 +0000 | |||
15 | @@ -27,6 +27,7 @@ | |||
16 | 27 | base_time_string | 27 | base_time_string |
17 | 28 | economy | 28 | economy |
18 | 29 | graphic | 29 | graphic |
19 | 30 | graphic_minimap_renderer | ||
20 | 30 | io_fileread | 31 | io_fileread |
21 | 31 | io_filesystem | 32 | io_filesystem |
22 | 32 | logic | 33 | logic |
23 | @@ -36,4 +37,6 @@ | |||
24 | 36 | profile | 37 | profile |
25 | 37 | scripting | 38 | scripting |
26 | 38 | wui | 39 | wui |
27 | 40 | wui_mapview_pixelfunctions | ||
28 | 41 | wui_overlay_manager | ||
29 | 39 | ) | 42 | ) |
30 | 40 | 43 | ||
31 | === modified file 'src/graphic/CMakeLists.txt' | |||
32 | --- src/graphic/CMakeLists.txt 2014-12-03 19:14:07 +0000 | |||
33 | +++ src/graphic/CMakeLists.txt 2014-12-04 20:54:56 +0000 | |||
34 | @@ -1,5 +1,8 @@ | |||
35 | 1 | add_subdirectory(text) | 1 | add_subdirectory(text) |
36 | 2 | 2 | ||
37 | 3 | # TODO(sirver): Separate this directory into a base directory and one | ||
38 | 4 | # that is Widelands aware (can include logic stuff). | ||
39 | 5 | |||
40 | 3 | wl_library(graphic_color | 6 | wl_library(graphic_color |
41 | 4 | SRCS | 7 | SRCS |
42 | 5 | color.h | 8 | color.h |
43 | @@ -77,14 +80,52 @@ | |||
44 | 77 | graphic_surface | 80 | graphic_surface |
45 | 78 | ) | 81 | ) |
46 | 79 | 82 | ||
47 | 83 | wl_library(graphic_game_renderer | ||
48 | 84 | SRCS | ||
49 | 85 | game_renderer.cc | ||
50 | 86 | game_renderer.h | ||
51 | 87 | gl/dither_program.cc | ||
52 | 88 | gl/dither_program.h | ||
53 | 89 | gl/fields_to_draw.h | ||
54 | 90 | gl/road_program.cc | ||
55 | 91 | gl/road_program.h | ||
56 | 92 | gl/terrain_program.cc | ||
57 | 93 | gl/terrain_program.h | ||
58 | 94 | DEPENDS | ||
59 | 95 | base_exceptions | ||
60 | 96 | base_geometry | ||
61 | 97 | base_log | ||
62 | 98 | base_macros | ||
63 | 99 | graphic | ||
64 | 100 | graphic_image_io | ||
65 | 101 | graphic_surface | ||
66 | 102 | io_filesystem | ||
67 | 103 | logic | ||
68 | 104 | wui_mapview_pixelfunctions | ||
69 | 105 | wui_overlay_manager | ||
70 | 106 | ) | ||
71 | 107 | |||
72 | 108 | wl_library(graphic_minimap_renderer | ||
73 | 109 | SRCS | ||
74 | 110 | minimap_renderer.cc | ||
75 | 111 | minimap_renderer.h | ||
76 | 112 | DEPENDS | ||
77 | 113 | base_geometry | ||
78 | 114 | base_macros | ||
79 | 115 | economy | ||
80 | 116 | graphic | ||
81 | 117 | graphic_image | ||
82 | 118 | graphic_surface | ||
83 | 119 | logic | ||
84 | 120 | wui_mapview_pixelfunctions | ||
85 | 121 | ) | ||
86 | 122 | |||
87 | 80 | wl_library(graphic | 123 | wl_library(graphic |
88 | 81 | SRCS | 124 | SRCS |
89 | 82 | align.cc | 125 | align.cc |
90 | 83 | align.h | 126 | align.h |
91 | 84 | animation.cc | 127 | animation.cc |
92 | 85 | animation.h | 128 | animation.h |
93 | 86 | colormap.cc | ||
94 | 87 | colormap.h | ||
95 | 88 | default_resolution.h | 129 | default_resolution.h |
96 | 89 | diranimations.h | 130 | diranimations.h |
97 | 90 | font.cc | 131 | font.cc |
98 | @@ -93,34 +134,21 @@ | |||
99 | 93 | font_handler.h | 134 | font_handler.h |
100 | 94 | font_handler1.cc | 135 | font_handler1.cc |
101 | 95 | font_handler1.h | 136 | font_handler1.h |
102 | 96 | game_renderer.cc | ||
103 | 97 | game_renderer.h | ||
104 | 98 | gl/blit_program.cc | 137 | gl/blit_program.cc |
105 | 99 | gl/blit_program.h | 138 | gl/blit_program.h |
106 | 100 | gl/dither_program.cc | ||
107 | 101 | gl/dither_program.h | ||
108 | 102 | gl/draw_line_program.cc | 139 | gl/draw_line_program.cc |
109 | 103 | gl/draw_line_program.h | 140 | gl/draw_line_program.h |
110 | 104 | gl/draw_rect_program.cc | 141 | gl/draw_rect_program.cc |
111 | 105 | gl/draw_rect_program.h | 142 | gl/draw_rect_program.h |
112 | 106 | gl/fields_to_draw.h | ||
113 | 107 | gl/fill_rect_program.cc | 143 | gl/fill_rect_program.cc |
114 | 108 | gl/fill_rect_program.h | 144 | gl/fill_rect_program.h |
115 | 109 | gl/game_renderer.cc | ||
116 | 110 | gl/game_renderer.h | ||
117 | 111 | gl/road_program.cc | ||
118 | 112 | gl/road_program.h | ||
119 | 113 | gl/system_headers.h | 145 | gl/system_headers.h |
120 | 114 | gl/terrain_program.cc | ||
121 | 115 | gl/terrain_program.h | ||
122 | 116 | graphic.cc | 146 | graphic.cc |
123 | 117 | graphic.h | 147 | graphic.h |
124 | 118 | image_transformations.cc | 148 | image_transformations.cc |
125 | 119 | image_transformations.h | 149 | image_transformations.h |
126 | 120 | in_memory_image.cc | 150 | in_memory_image.cc |
127 | 121 | in_memory_image.h | 151 | in_memory_image.h |
128 | 122 | minimap_renderer.cc | ||
129 | 123 | minimap_renderer.h | ||
130 | 124 | rendertarget.cc | 152 | rendertarget.cc |
131 | 125 | rendertarget.h | 153 | rendertarget.h |
132 | 126 | richtext.cc | 154 | richtext.cc |
133 | @@ -139,7 +167,6 @@ | |||
134 | 139 | base_log | 167 | base_log |
135 | 140 | base_macros | 168 | base_macros |
136 | 141 | build_info | 169 | build_info |
137 | 142 | economy | ||
138 | 143 | graphic_color | 170 | graphic_color |
139 | 144 | graphic_image | 171 | graphic_image |
140 | 145 | graphic_image_io | 172 | graphic_image_io |
141 | @@ -154,6 +181,6 @@ | |||
142 | 154 | profile | 181 | profile |
143 | 155 | scripting | 182 | scripting |
144 | 156 | sound | 183 | sound |
146 | 157 | wui | 184 | wui_overlay_manager |
147 | 158 | wui_text_layout | 185 | wui_text_layout |
148 | 159 | ) | 186 | ) |
149 | 160 | 187 | ||
150 | === removed file 'src/graphic/colormap.cc' | |||
151 | --- src/graphic/colormap.cc 2014-07-17 13:26:23 +0000 | |||
152 | +++ src/graphic/colormap.cc 1970-01-01 00:00:00 +0000 | |||
153 | @@ -1,58 +0,0 @@ | |||
154 | 1 | /* | ||
155 | 2 | * Copyright (C) 2002-2004, 2006, 2009 by the Widelands Development Team | ||
156 | 3 | * | ||
157 | 4 | * This program is free software; you can redistribute it and/or | ||
158 | 5 | * modify it under the terms of the GNU General Public License | ||
159 | 6 | * as published by the Free Software Foundation; either version 2 | ||
160 | 7 | * of the License, or (at your option) any later version. | ||
161 | 8 | * | ||
162 | 9 | * This program is distributed in the hope that it will be useful, | ||
163 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
164 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
165 | 12 | * GNU General Public License for more details. | ||
166 | 13 | * | ||
167 | 14 | * You should have received a copy of the GNU General Public License | ||
168 | 15 | * along with this program; if not, write to the Free Software | ||
169 | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
170 | 17 | * | ||
171 | 18 | */ | ||
172 | 19 | |||
173 | 20 | #include "graphic/colormap.h" | ||
174 | 21 | |||
175 | 22 | #include <algorithm> | ||
176 | 23 | #include <cassert> | ||
177 | 24 | #include <cstdlib> | ||
178 | 25 | #include <cstring> | ||
179 | 26 | |||
180 | 27 | /** | ||
181 | 28 | * Create a new Colormap, taking the palette as a parameter. | ||
182 | 29 | * It automatically creates the colormap for shading. | ||
183 | 30 | */ | ||
184 | 31 | Colormap::Colormap (const SDL_Color & pal, const SDL_PixelFormat & format) { | ||
185 | 32 | memcpy(palette, &pal, sizeof(palette)); | ||
186 | 33 | |||
187 | 34 | assert(format.BytesPerPixel == 4); | ||
188 | 35 | colormap = malloc(format.BytesPerPixel * 65536); | ||
189 | 36 | |||
190 | 37 | for (int i = 0; i < 256; ++i) | ||
191 | 38 | for (int j = 0; j < 256; ++j) { | ||
192 | 39 | int32_t shade = (j < 128) ? j : (j - 256); | ||
193 | 40 | shade = 256 + 2 * shade; | ||
194 | 41 | |||
195 | 42 | const uint32_t r = std::min<uint32_t>((palette[i].r * shade) >> 8, 255); | ||
196 | 43 | const uint32_t g = std::min<uint32_t>((palette[i].g * shade) >> 8, 255); | ||
197 | 44 | const uint32_t b = std::min<uint32_t>((palette[i].b * shade) >> 8, 255); | ||
198 | 45 | |||
199 | 46 | const uint32_t value = | ||
200 | 47 | SDL_MapRGB(&const_cast<SDL_PixelFormat &>(format), r, g, b); | ||
201 | 48 | static_cast<uint32_t *>(colormap)[(j << 8) | i] = value; | ||
202 | 49 | } | ||
203 | 50 | } | ||
204 | 51 | |||
205 | 52 | /** | ||
206 | 53 | * Clean up. | ||
207 | 54 | */ | ||
208 | 55 | Colormap::~Colormap () | ||
209 | 56 | { | ||
210 | 57 | free(colormap); | ||
211 | 58 | } | ||
212 | 59 | 0 | ||
213 | === removed file 'src/graphic/colormap.h' | |||
214 | --- src/graphic/colormap.h 2014-07-12 12:25:21 +0000 | |||
215 | +++ src/graphic/colormap.h 1970-01-01 00:00:00 +0000 | |||
216 | @@ -1,51 +0,0 @@ | |||
217 | 1 | /* | ||
218 | 2 | * Copyright (C) 2002-2004, 2006, 2008 by the Widelands Development Team | ||
219 | 3 | * | ||
220 | 4 | * This program is free software; you can redistribute it and/or | ||
221 | 5 | * modify it under the terms of the GNU General Public License | ||
222 | 6 | * as published by the Free Software Foundation; either version 2 | ||
223 | 7 | * of the License, or (at your option) any later version. | ||
224 | 8 | * | ||
225 | 9 | * This program is distributed in the hope that it will be useful, | ||
226 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
227 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
228 | 12 | * GNU General Public License for more details. | ||
229 | 13 | * | ||
230 | 14 | * You should have received a copy of the GNU General Public License | ||
231 | 15 | * along with this program; if not, write to the Free Software | ||
232 | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
233 | 17 | * | ||
234 | 18 | */ | ||
235 | 19 | |||
236 | 20 | #ifndef WL_GRAPHIC_COLORMAP_H | ||
237 | 21 | #define WL_GRAPHIC_COLORMAP_H | ||
238 | 22 | |||
239 | 23 | #include <SDL_video.h> | ||
240 | 24 | |||
241 | 25 | #include "graphic/color.h" | ||
242 | 26 | |||
243 | 27 | /** | ||
244 | 28 | * Colormap contains a palette and lookup table for use with ground textures. | ||
245 | 29 | */ | ||
246 | 30 | class Colormap { | ||
247 | 31 | public: | ||
248 | 32 | Colormap (const SDL_Color &, const SDL_PixelFormat & fmt); | ||
249 | 33 | ~Colormap (); | ||
250 | 34 | |||
251 | 35 | // Returns the palette of this colormap (256 entries of RGB Colors); | ||
252 | 36 | SDL_Color * get_palette() {return palette;} | ||
253 | 37 | |||
254 | 38 | // Returns the internally calculated colormap used in the renderer. | ||
255 | 39 | void * get_colormap () const {return colormap;} | ||
256 | 40 | |||
257 | 41 | private: | ||
258 | 42 | SDL_Color palette[256]; | ||
259 | 43 | |||
260 | 44 | /// maps 8 bit color and brightness value to the shaded color. | ||
261 | 45 | /// \note Brightness is currently 8 bits. Restricting brightness to 64 or | ||
262 | 46 | /// less shades would greatly reduce the size of this table, and thus | ||
263 | 47 | /// improve memory cache impact inside the renderer. | ||
264 | 48 | void * colormap; | ||
265 | 49 | }; | ||
266 | 50 | |||
267 | 51 | #endif // end of include guard: WL_GRAPHIC_COLORMAP_H | ||
268 | 52 | 0 | ||
269 | === modified file 'src/graphic/game_renderer.cc' | |||
270 | --- src/graphic/game_renderer.cc 2014-09-27 18:53:55 +0000 | |||
271 | +++ src/graphic/game_renderer.cc 2014-12-04 20:54:56 +0000 | |||
272 | @@ -19,82 +19,227 @@ | |||
273 | 19 | 19 | ||
274 | 20 | #include "graphic/game_renderer.h" | 20 | #include "graphic/game_renderer.h" |
275 | 21 | 21 | ||
277 | 22 | #include "base/macros.h" | 22 | #include <memory> |
278 | 23 | |||
279 | 24 | #include "graphic/gl/dither_program.h" | ||
280 | 25 | #include "graphic/gl/fields_to_draw.h" | ||
281 | 26 | #include "graphic/gl/road_program.h" | ||
282 | 27 | #include "graphic/gl/terrain_program.h" | ||
283 | 23 | #include "graphic/graphic.h" | 28 | #include "graphic/graphic.h" |
284 | 24 | #include "graphic/rendertarget.h" | 29 | #include "graphic/rendertarget.h" |
285 | 30 | #include "graphic/surface.h" | ||
286 | 25 | #include "logic/editor_game_base.h" | 31 | #include "logic/editor_game_base.h" |
287 | 26 | #include "logic/player.h" | 32 | #include "logic/player.h" |
288 | 33 | #include "logic/world/world.h" | ||
289 | 34 | #include "wui/mapviewpixelconstants.h" | ||
290 | 27 | #include "wui/mapviewpixelfunctions.h" | 35 | #include "wui/mapviewpixelfunctions.h" |
291 | 28 | #include "wui/overlay_manager.h" | 36 | #include "wui/overlay_manager.h" |
292 | 29 | 37 | ||
293 | 38 | // Explanation of how drawing works: | ||
294 | 39 | // Schematic of triangle neighborhood: | ||
295 | 40 | // | ||
296 | 41 | // * | ||
297 | 42 | // / \ | ||
298 | 43 | // / u \ | ||
299 | 44 | // (f)/ \ | ||
300 | 45 | // *------*------* (r) | ||
301 | 46 | // \ l / \ r / \ | ||
302 | 47 | // \ / \ / \ | ||
303 | 48 | // \/ d \/ rr \ | ||
304 | 49 | // *------*------* (br) | ||
305 | 50 | // \ dd / | ||
306 | 51 | // \ / | ||
307 | 52 | // \/ | ||
308 | 53 | // * | ||
309 | 54 | // | ||
310 | 55 | // Each field (f) owns two triangles: (r)ight & (d)own. When we look at the | ||
311 | 56 | // field, we have to make sure to schedule drawing the triangles. This is done | ||
312 | 57 | // by of these triangles is done by TerrainProgram. | ||
313 | 58 | // | ||
314 | 59 | // To draw dithered edges, we have to look at the neighboring triangles for the | ||
315 | 60 | // two triangles too: If a neighboring triangle has another texture and our | ||
316 | 61 | // dither layer is smaller, we have to draw a dithering triangle too - this lets the neighboring | ||
317 | 62 | // texture | ||
318 | 63 | // bleed into our triangle. | ||
319 | 64 | // | ||
320 | 65 | // The dither triangle is the triangle that should be partially (either r or | ||
321 | 66 | // d). Example: if r and d have different textures and r.dither_layer > | ||
322 | 67 | // d.dither_layer, then we will repaint d with the dither texture as mask. | ||
323 | 68 | |||
324 | 69 | std::unique_ptr<TerrainProgram> GameRenderer::terrain_program_; | ||
325 | 70 | std::unique_ptr<DitherProgram> GameRenderer::dither_program_; | ||
326 | 71 | std::unique_ptr<RoadProgram> GameRenderer::road_program_; | ||
327 | 72 | |||
328 | 73 | namespace { | ||
329 | 74 | |||
330 | 30 | using namespace Widelands; | 75 | using namespace Widelands; |
331 | 31 | 76 | ||
370 | 32 | GameRenderer::GameRenderer() | 77 | // Returns the brightness value in [0, 1.] for 'fcoords' at 'gametime' for |
371 | 33 | { | 78 | // 'player' (which can be nullptr). |
372 | 34 | } | 79 | float field_brightness(const FCoords& fcoords, |
373 | 35 | 80 | const uint32_t gametime, | |
374 | 36 | GameRenderer::~GameRenderer() | 81 | const Map& map, |
375 | 37 | { | 82 | const Player* const player) { |
376 | 38 | } | 83 | uint32_t brightness = 144 + fcoords.field->get_brightness(); |
377 | 39 | 84 | brightness = std::min<uint32_t>(255, (brightness * 255) / 160); | |
378 | 40 | void GameRenderer::rendermap | 85 | |
379 | 41 | (RenderTarget & dst, | 86 | if (player && !player->see_all()) { |
380 | 42 | const Widelands::EditorGameBase & egbase, | 87 | const Player::Field& pf = player->fields()[Map::get_index(fcoords, map.get_width())]; |
381 | 43 | const Widelands::Player & player, | 88 | if (pf.vision == 0) { |
382 | 44 | const Point & viewofs) | 89 | return 0.; |
383 | 45 | { | 90 | } else if (pf.vision == 1) { |
384 | 46 | m_dst = &dst; | 91 | static const uint32_t kDecayTimeInMs = 20000; |
385 | 47 | m_dst_offset = -viewofs; | 92 | const Duration time_ago = gametime - pf.time_node_last_unseen; |
386 | 48 | m_egbase = &egbase; | 93 | if (time_ago < kDecayTimeInMs) { |
387 | 49 | m_player = &player; | 94 | brightness = (brightness * (2 * kDecayTimeInMs - time_ago)) / (2 * kDecayTimeInMs); |
388 | 50 | 95 | } else { | |
389 | 51 | draw_wrapper(); | 96 | brightness = brightness / 2; |
390 | 52 | } | 97 | } |
391 | 53 | 98 | } | |
392 | 54 | void GameRenderer::rendermap | 99 | } |
393 | 55 | (RenderTarget & dst, | 100 | return brightness / 255.; |
394 | 56 | const Widelands::EditorGameBase & egbase, | 101 | } |
395 | 57 | const Point & viewofs) | 102 | |
396 | 58 | { | 103 | // Returns the road that should be rendered here. The format is like in field, |
397 | 59 | m_dst = &dst; | 104 | // but this is not the physically present road, but the one that should be |
398 | 60 | m_dst_offset = -viewofs; | 105 | // drawn (i.e. taking into account if there is fog of war involved or road |
399 | 61 | m_egbase = &egbase; | 106 | // building overlays enabled). |
400 | 62 | m_player = nullptr; | 107 | uint8_t field_roads(const FCoords& coords, const Map& map, const Player* const player) { |
401 | 63 | 108 | uint8_t roads; | |
402 | 64 | draw_wrapper(); | 109 | if (player && !player->see_all()) { |
403 | 65 | } | 110 | const Player::Field& pf = player->fields()[Map::get_index(coords, map.get_width())]; |
404 | 66 | 111 | roads = pf.roads | map.overlay_manager().get_road_overlay(coords); | |
405 | 67 | void GameRenderer::draw_wrapper() | 112 | } else { |
406 | 68 | { | 113 | roads = coords.field->get_roads(); |
407 | 69 | Point tl_map = m_dst->get_offset() - m_dst_offset; | 114 | } |
408 | 115 | roads |= map.overlay_manager().get_road_overlay(coords); | ||
409 | 116 | return roads; | ||
410 | 117 | } | ||
411 | 118 | |||
412 | 119 | } // namespace | ||
413 | 120 | |||
414 | 121 | GameRenderer::GameRenderer() { | ||
415 | 122 | } | ||
416 | 123 | |||
417 | 124 | GameRenderer::~GameRenderer() { | ||
418 | 125 | } | ||
419 | 126 | |||
420 | 127 | void GameRenderer::rendermap(RenderTarget& dst, | ||
421 | 128 | const Widelands::EditorGameBase& egbase, | ||
422 | 129 | const Point& view_offset, | ||
423 | 130 | |||
424 | 131 | const Widelands::Player& player) { | ||
425 | 132 | draw(dst, egbase, view_offset, &player); | ||
426 | 133 | } | ||
427 | 134 | |||
428 | 135 | void GameRenderer::rendermap(RenderTarget& dst, | ||
429 | 136 | const Widelands::EditorGameBase& egbase, | ||
430 | 137 | const Point& view_offset) { | ||
431 | 138 | draw(dst, egbase, view_offset, nullptr); | ||
432 | 139 | } | ||
433 | 140 | |||
434 | 141 | void GameRenderer::draw(RenderTarget& dst, | ||
435 | 142 | const EditorGameBase& egbase, | ||
436 | 143 | const Point& view_offset, | ||
437 | 144 | const Player* player) { | ||
438 | 145 | if (terrain_program_ == nullptr) { | ||
439 | 146 | terrain_program_.reset(new TerrainProgram()); | ||
440 | 147 | dither_program_.reset(new DitherProgram()); | ||
441 | 148 | road_program_.reset(new RoadProgram()); | ||
442 | 149 | } | ||
443 | 150 | |||
444 | 151 | Point tl_map = dst.get_offset() + view_offset; | ||
445 | 70 | 152 | ||
446 | 71 | assert(tl_map.x >= 0); // divisions involving negative numbers are bad | 153 | assert(tl_map.x >= 0); // divisions involving negative numbers are bad |
447 | 72 | assert(tl_map.y >= 0); | 154 | assert(tl_map.y >= 0); |
448 | 73 | 155 | ||
453 | 74 | m_minfx = tl_map.x / TRIANGLE_WIDTH - 1; | 156 | int minfx = tl_map.x / TRIANGLE_WIDTH - 1; |
454 | 75 | m_minfy = tl_map.y / TRIANGLE_HEIGHT - 1; | 157 | int minfy = tl_map.y / TRIANGLE_HEIGHT - 1; |
455 | 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; |
456 | 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; |
457 | 78 | 160 | ||
458 | 79 | // fudge for triangle boundary effects and for height differences | 161 | // fudge for triangle boundary effects and for height differences |
465 | 80 | m_minfx -= 1; | 162 | minfx -= 1; |
466 | 81 | m_minfy -= 1; | 163 | minfy -= 1; |
467 | 82 | m_maxfx += 1; | 164 | maxfx += 1; |
468 | 83 | m_maxfy += 10; | 165 | maxfy += 10; |
469 | 84 | 166 | ||
470 | 85 | draw(); | 167 | |
471 | 168 | Surface* surface = dst.get_surface(); | ||
472 | 169 | if (!surface) | ||
473 | 170 | return; | ||
474 | 171 | |||
475 | 172 | const Rect& bounding_rect = dst.get_rect(); | ||
476 | 173 | const Point surface_offset = bounding_rect.top_left() + dst.get_offset() - view_offset; | ||
477 | 174 | |||
478 | 175 | glScissor(bounding_rect.x, | ||
479 | 176 | surface->height() - bounding_rect.y - bounding_rect.h, | ||
480 | 177 | bounding_rect.w, | ||
481 | 178 | bounding_rect.h); | ||
482 | 179 | glEnable(GL_SCISSOR_TEST); | ||
483 | 180 | |||
484 | 181 | Map& map = egbase.map(); | ||
485 | 182 | const uint32_t gametime = egbase.get_gametime(); | ||
486 | 183 | |||
487 | 184 | FieldsToDraw fields_to_draw(minfx, maxfx, minfy, maxfy); | ||
488 | 185 | for (int32_t fy = minfy; fy <= maxfy; ++fy) { | ||
489 | 186 | for (int32_t fx = minfx; fx <= maxfx; ++fx) { | ||
490 | 187 | FieldsToDraw::Field& f = | ||
491 | 188 | *fields_to_draw.mutable_field(fields_to_draw.calculate_index(fx, fy)); | ||
492 | 189 | |||
493 | 190 | f.fx = fx; | ||
494 | 191 | f.fy = fy; | ||
495 | 192 | |||
496 | 193 | Coords coords(fx, fy); | ||
497 | 194 | int x, y; | ||
498 | 195 | MapviewPixelFunctions::get_basepix(coords, x, y); | ||
499 | 196 | |||
500 | 197 | map.normalize_coords(coords); | ||
501 | 198 | const FCoords& fcoords = map.get_fcoords(coords); | ||
502 | 199 | |||
503 | 200 | f.texture_x = float(x) / kTextureSideLength; | ||
504 | 201 | f.texture_y = float(y) / kTextureSideLength; | ||
505 | 202 | |||
506 | 203 | f.gl_x = f.pixel_x = x + surface_offset.x; | ||
507 | 204 | f.gl_y = f.pixel_y = y + surface_offset.y - fcoords.field->get_height() * HEIGHT_FACTOR; | ||
508 | 205 | surface->pixel_to_gl(&f.gl_x, &f.gl_y); | ||
509 | 206 | |||
510 | 207 | f.ter_d = fcoords.field->terrain_d(); | ||
511 | 208 | f.ter_r = fcoords.field->terrain_r(); | ||
512 | 209 | |||
513 | 210 | f.brightness = field_brightness(fcoords, gametime, map, player); | ||
514 | 211 | |||
515 | 212 | f.roads = field_roads(fcoords, map, player); | ||
516 | 213 | } | ||
517 | 214 | } | ||
518 | 215 | |||
519 | 216 | const World& world = egbase.world(); | ||
520 | 217 | terrain_program_->draw(gametime, world.terrains(), fields_to_draw); | ||
521 | 218 | dither_program_->draw(gametime, world.terrains(), fields_to_draw); | ||
522 | 219 | road_program_->draw(*surface, fields_to_draw); | ||
523 | 220 | |||
524 | 221 | draw_objects(dst, egbase, view_offset, player, minfx, maxfx, minfy, maxfy); | ||
525 | 222 | |||
526 | 223 | glDisable(GL_SCISSOR_TEST); | ||
527 | 86 | } | 224 | } |
528 | 87 | 225 | ||
531 | 88 | void GameRenderer::draw_objects() | 226 | void GameRenderer::draw_objects(RenderTarget& dst, |
532 | 89 | { | 227 | const EditorGameBase& egbase, |
533 | 228 | const Point& view_offset, | ||
534 | 229 | const Player* player, | ||
535 | 230 | int minfx, | ||
536 | 231 | int maxfx, | ||
537 | 232 | int minfy, | ||
538 | 233 | int maxfy) { | ||
539 | 234 | // TODO(sirver): this should use FieldsToDraw. Would simplify this function a lot. | ||
540 | 90 | static const uint32_t F = 0; | 235 | static const uint32_t F = 0; |
541 | 91 | static const uint32_t R = 1; | 236 | static const uint32_t R = 1; |
542 | 92 | static const uint32_t BL = 2; | 237 | static const uint32_t BL = 2; |
543 | 93 | static const uint32_t BR = 3; | 238 | static const uint32_t BR = 3; |
545 | 94 | const Map & map = m_egbase->map(); | 239 | const Map & map = egbase.map(); |
546 | 95 | 240 | ||
549 | 96 | for (int32_t fy = m_minfy; fy <= m_maxfy; ++fy) { | 241 | for (int32_t fy = minfy; fy <= maxfy; ++fy) { |
550 | 97 | for (int32_t fx = m_minfx; fx <= m_maxfx; ++fx) { | 242 | for (int32_t fx = minfx; fx <= maxfx; ++fx) { |
551 | 98 | Coords ncoords(fx, fy); | 243 | Coords ncoords(fx, fy); |
552 | 99 | map.normalize_coords(ncoords); | 244 | map.normalize_coords(ncoords); |
553 | 100 | FCoords coords[4]; | 245 | FCoords coords[4]; |
554 | @@ -109,7 +254,7 @@ | |||
555 | 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); |
556 | 110 | for (uint32_t d = 0; d < 4; ++d) { | 255 | for (uint32_t d = 0; d < 4; ++d) { |
557 | 111 | pos[d].y -= coords[d].field->get_height() * HEIGHT_FACTOR; | 256 | pos[d].y -= coords[d].field->get_height() * HEIGHT_FACTOR; |
559 | 112 | pos[d] += m_dst_offset; | 257 | pos[d] -= view_offset; |
560 | 113 | } | 258 | } |
561 | 114 | 259 | ||
562 | 115 | PlayerNumber owner_number[4]; | 260 | PlayerNumber owner_number[4]; |
563 | @@ -120,9 +265,9 @@ | |||
564 | 120 | for (uint32_t d = 0; d < 4; ++d) | 265 | for (uint32_t d = 0; d < 4; ++d) |
565 | 121 | isborder[d] = coords[d].field->is_border(); | 266 | isborder[d] = coords[d].field->is_border(); |
566 | 122 | 267 | ||
568 | 123 | if (m_player && !m_player->see_all()) { | 268 | if (player && !player->see_all()) { |
569 | 124 | for (uint32_t d = 0; d < 4; ++d) { | 269 | for (uint32_t d = 0; d < 4; ++d) { |
571 | 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())]; |
572 | 126 | vision[d] = pf.vision; | 271 | vision[d] = pf.vision; |
573 | 127 | if (pf.vision == 1) { | 272 | if (pf.vision == 1) { |
574 | 128 | owner_number[d] = pf.owner; | 273 | owner_number[d] = pf.owner; |
575 | @@ -132,32 +277,32 @@ | |||
576 | 132 | } | 277 | } |
577 | 133 | 278 | ||
578 | 134 | if (isborder[F]) { | 279 | if (isborder[F]) { |
580 | 135 | const Player & owner = m_egbase->player(owner_number[F]); | 280 | const Player & owner = egbase.player(owner_number[F]); |
581 | 136 | uint32_t const anim_idx = owner.tribe().frontier_animation(); | 281 | uint32_t const anim_idx = owner.tribe().frontier_animation(); |
582 | 137 | if (vision[F]) | 282 | if (vision[F]) |
584 | 138 | m_dst->drawanim(pos[F], anim_idx, 0, &owner); | 283 | dst.drawanim(pos[F], anim_idx, 0, &owner); |
585 | 139 | for (uint32_t d = 1; d < 4; ++d) { | 284 | for (uint32_t d = 1; d < 4; ++d) { |
586 | 140 | if | 285 | if |
587 | 141 | ((vision[F] || vision[d]) && | 286 | ((vision[F] || vision[d]) && |
588 | 142 | isborder[d] && | 287 | isborder[d] && |
589 | 143 | (owner_number[d] == owner_number[F] || !owner_number[d])) | 288 | (owner_number[d] == owner_number[F] || !owner_number[d])) |
590 | 144 | { | 289 | { |
592 | 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); |
593 | 146 | } | 291 | } |
594 | 147 | } | 292 | } |
595 | 148 | } | 293 | } |
596 | 149 | 294 | ||
597 | 150 | if (1 < vision[F]) { // Render stuff that belongs to the node. | 295 | if (1 < vision[F]) { // Render stuff that belongs to the node. |
598 | 151 | if (BaseImmovable * const imm = coords[F].field->get_immovable()) | 296 | if (BaseImmovable * const imm = coords[F].field->get_immovable()) |
600 | 152 | imm->draw(*m_egbase, *m_dst, coords[F], pos[F]); | 297 | imm->draw(egbase, dst, coords[F], pos[F]); |
601 | 153 | for | 298 | for |
602 | 154 | (Bob * bob = coords[F].field->get_first_bob(); | 299 | (Bob * bob = coords[F].field->get_first_bob(); |
603 | 155 | bob; | 300 | bob; |
604 | 156 | bob = bob->get_next_bob()) | 301 | bob = bob->get_next_bob()) |
606 | 157 | bob->draw(*m_egbase, *m_dst, pos[F]); | 302 | bob->draw(egbase, dst, pos[F]); |
607 | 158 | } else if (vision[F] == 1) { | 303 | } else if (vision[F] == 1) { |
610 | 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())]; |
611 | 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; |
612 | 161 | if | 306 | if |
613 | 162 | (const MapObjectDescr * const map_object_descr = | 307 | (const MapObjectDescr * const map_object_descr = |
614 | 163 | f_pl.map_object_descr[TCoords<>::None]) | 308 | f_pl.map_object_descr[TCoords<>::None]) |
615 | @@ -193,7 +338,7 @@ | |||
616 | 193 | 338 | ||
617 | 194 | if (cur_frame) // not the first frame | 339 | if (cur_frame) // not the first frame |
618 | 195 | // draw the prev frame from top to where next image will be drawing | 340 | // draw the prev frame from top to where next image will be drawing |
620 | 196 | m_dst->drawanimrect | 341 | dst.drawanimrect |
621 | 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)); |
622 | 198 | else if (csinf.was) { | 343 | else if (csinf.was) { |
623 | 199 | // Is the first frame, but there was another building here before, | 344 | // Is the first frame, but there was another building here before, |
624 | @@ -204,11 +349,11 @@ | |||
625 | 204 | } catch (MapObjectDescr::AnimationNonexistent &) { | 349 | } catch (MapObjectDescr::AnimationNonexistent &) { |
626 | 205 | a = csinf.was->get_animation("idle"); | 350 | a = csinf.was->get_animation("idle"); |
627 | 206 | } | 351 | } |
629 | 207 | m_dst->drawanimrect | 352 | dst.drawanimrect |
630 | 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)); |
631 | 209 | } | 354 | } |
632 | 210 | assert(lines <= h); | 355 | assert(lines <= h); |
634 | 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)); |
635 | 212 | } else if (upcast(const BuildingDescr, building, map_object_descr)) { | 357 | } else if (upcast(const BuildingDescr, building, map_object_descr)) { |
636 | 213 | // this is a building therefore we either draw unoccupied or idle animation | 358 | // this is a building therefore we either draw unoccupied or idle animation |
637 | 214 | uint32_t pic; | 359 | uint32_t pic; |
638 | @@ -217,11 +362,11 @@ | |||
639 | 217 | } catch (MapObjectDescr::AnimationNonexistent &) { | 362 | } catch (MapObjectDescr::AnimationNonexistent &) { |
640 | 218 | pic = building->get_animation("idle"); | 363 | pic = building->get_animation("idle"); |
641 | 219 | } | 364 | } |
643 | 220 | m_dst->drawanim(pos[F], pic, 0, owner); | 365 | dst.drawanim(pos[F], pic, 0, owner); |
644 | 221 | } else if (const uint32_t pic = map_object_descr->main_animation()) { | 366 | } else if (const uint32_t pic = map_object_descr->main_animation()) { |
646 | 222 | m_dst->drawanim(pos[F], pic, 0, owner); | 367 | dst.drawanim(pos[F], pic, 0, owner); |
647 | 223 | } else if (map_object_descr->type() == MapObjectType::FLAG) { | 368 | } else if (map_object_descr->type() == MapObjectType::FLAG) { |
649 | 224 | m_dst->drawanim(pos[F], owner->tribe().flag_animation(), 0, owner); | 369 | dst.drawanim(pos[F], owner->tribe().flag_animation(), 0, owner); |
650 | 225 | } | 370 | } |
651 | 226 | } | 371 | } |
652 | 227 | } | 372 | } |
653 | @@ -239,7 +384,7 @@ | |||
654 | 239 | (const OverlayManager::OverlayInfo * it = overlay_info; | 384 | (const OverlayManager::OverlayInfo * it = overlay_info; |
655 | 240 | it < end; | 385 | it < end; |
656 | 241 | ++it) | 386 | ++it) |
658 | 242 | m_dst->blit(pos[F] - it->hotspot, it->pic); | 387 | dst.blit(pos[F] - it->hotspot, it->pic); |
659 | 243 | } | 388 | } |
660 | 244 | 389 | ||
661 | 245 | { | 390 | { |
662 | @@ -259,7 +404,7 @@ | |||
663 | 259 | (OverlayManager::OverlayInfo const * it = overlay_info; | 404 | (OverlayManager::OverlayInfo const * it = overlay_info; |
664 | 260 | it < end; | 405 | it < end; |
665 | 261 | ++it) | 406 | ++it) |
667 | 262 | m_dst->blit(tripos - it->hotspot, it->pic); | 407 | dst.blit(tripos - it->hotspot, it->pic); |
668 | 263 | } | 408 | } |
669 | 264 | 409 | ||
670 | 265 | { | 410 | { |
671 | @@ -279,7 +424,7 @@ | |||
672 | 279 | (OverlayManager::OverlayInfo const * it = overlay_info; | 424 | (OverlayManager::OverlayInfo const * it = overlay_info; |
673 | 280 | it < end; | 425 | it < end; |
674 | 281 | ++it) | 426 | ++it) |
676 | 282 | m_dst->blit(tripos - it->hotspot, it->pic); | 427 | dst.blit(tripos - it->hotspot, it->pic); |
677 | 283 | } | 428 | } |
678 | 284 | } | 429 | } |
679 | 285 | } | 430 | } |
680 | 286 | 431 | ||
681 | === modified file 'src/graphic/game_renderer.h' | |||
682 | --- src/graphic/game_renderer.h 2014-09-27 18:53:55 +0000 | |||
683 | +++ src/graphic/game_renderer.h 2014-12-04 20:54:56 +0000 | |||
684 | @@ -20,17 +20,22 @@ | |||
685 | 20 | #ifndef WL_GRAPHIC_GAME_RENDERER_H | 20 | #ifndef WL_GRAPHIC_GAME_RENDERER_H |
686 | 21 | #define WL_GRAPHIC_GAME_RENDERER_H | 21 | #define WL_GRAPHIC_GAME_RENDERER_H |
687 | 22 | 22 | ||
689 | 23 | #include <boost/utility.hpp> | 23 | #include <memory> |
690 | 24 | 24 | ||
691 | 25 | #include "base/macros.h" | 25 | #include "base/macros.h" |
692 | 26 | #include "base/point.h" | 26 | #include "base/point.h" |
693 | 27 | #include "graphic/gl/utils.h" | ||
694 | 27 | 28 | ||
695 | 28 | namespace Widelands { | 29 | namespace Widelands { |
696 | 29 | class Player; | 30 | class Player; |
697 | 30 | class EditorGameBase; | 31 | class EditorGameBase; |
698 | 31 | } | 32 | } |
699 | 32 | 33 | ||
700 | 34 | class DitherProgram; | ||
701 | 33 | class RenderTarget; | 35 | class RenderTarget; |
702 | 36 | class RoadProgram; | ||
703 | 37 | class TerrainProgram; | ||
704 | 38 | |||
705 | 34 | 39 | ||
706 | 35 | /** | 40 | /** |
707 | 36 | * This abstract base class renders the main game view into an | 41 | * This abstract base class renders the main game view into an |
708 | @@ -45,56 +50,41 @@ | |||
709 | 45 | class GameRenderer { | 50 | class GameRenderer { |
710 | 46 | public: | 51 | public: |
711 | 47 | GameRenderer(); | 52 | GameRenderer(); |
759 | 48 | virtual ~GameRenderer(); | 53 | ~GameRenderer(); |
760 | 49 | 54 | ||
761 | 50 | /** | 55 | // Renders the map from a player's point of view into the given |
762 | 51 | * Renders the map from a player's point of view into the | 56 | // drawing window. 'view_offset' is the offset of the upper left |
763 | 52 | * given drawing window. | 57 | // corner of the window into the map, in pixels. |
764 | 53 | * | 58 | void rendermap(RenderTarget& dst, |
765 | 54 | * @param viewofs is the offset of the upper left corner of | 59 | const Widelands::EditorGameBase& egbase, |
766 | 55 | * the window into the map, in pixels. | 60 | const Point& view_offset, |
767 | 56 | */ | 61 | const Widelands::Player& player); |
768 | 57 | void rendermap | 62 | |
769 | 58 | (RenderTarget & dst, | 63 | // Renders the map from an omniscient perspective. This is used |
770 | 59 | const Widelands::EditorGameBase & egbase, | 64 | // for spectators, players that see all, and in the editor. |
771 | 60 | const Widelands::Player & player, | 65 | void rendermap(RenderTarget& dst, const Widelands::EditorGameBase& egbase, const Point& view_offset); |
725 | 61 | const Point & viewofs); | ||
726 | 62 | |||
727 | 63 | /** | ||
728 | 64 | * Renders the map from an omniscient perspective. | ||
729 | 65 | * This is used for spectators, players that see all, and in the editor. | ||
730 | 66 | */ | ||
731 | 67 | void rendermap | ||
732 | 68 | (RenderTarget & dst, | ||
733 | 69 | const Widelands::EditorGameBase & egbase, | ||
734 | 70 | const Point & viewofs); | ||
735 | 71 | |||
736 | 72 | protected: | ||
737 | 73 | virtual void draw() = 0; | ||
738 | 74 | |||
739 | 75 | void draw_objects(); | ||
740 | 76 | |||
741 | 77 | /** | ||
742 | 78 | * The following variables, which are setup by @ref rendermap, | ||
743 | 79 | * are only valid during rendering, | ||
744 | 80 | * and should be treated as read-only by derived classes. | ||
745 | 81 | */ | ||
746 | 82 | /*@{*/ | ||
747 | 83 | RenderTarget * m_dst; | ||
748 | 84 | Widelands::EditorGameBase const * m_egbase; | ||
749 | 85 | Widelands::Player const * m_player; | ||
750 | 86 | |||
751 | 87 | /// Translation from map pixel coordinates to @ref m_dst pixel coordinates | ||
752 | 88 | Point m_dst_offset; | ||
753 | 89 | |||
754 | 90 | int32_t m_minfx; | ||
755 | 91 | int32_t m_minfy; | ||
756 | 92 | int32_t m_maxfx; | ||
757 | 93 | int32_t m_maxfy; | ||
758 | 94 | /*@}*/ | ||
772 | 95 | 66 | ||
773 | 96 | private: | 67 | private: |
775 | 97 | void draw_wrapper(); | 68 | static std::unique_ptr<TerrainProgram> terrain_program_; |
776 | 69 | static std::unique_ptr<DitherProgram> dither_program_; | ||
777 | 70 | static std::unique_ptr<RoadProgram> road_program_; | ||
778 | 71 | |||
779 | 72 | // Draw the map for the given parameters (see rendermap). 'player' | ||
780 | 73 | // can be nullptr in which case the whole map is drawn. | ||
781 | 74 | void draw(RenderTarget& dst, | ||
782 | 75 | const Widelands::EditorGameBase& egbase, | ||
783 | 76 | const Point& view_offset, | ||
784 | 77 | const Widelands::Player* player); | ||
785 | 78 | |||
786 | 79 | // Draws the objects (animations & overlays). | ||
787 | 80 | void draw_objects(RenderTarget& dst, | ||
788 | 81 | const Widelands::EditorGameBase& egbase, | ||
789 | 82 | const Point& view_offset, | ||
790 | 83 | const Widelands::Player* player, | ||
791 | 84 | int minfx, | ||
792 | 85 | int maxfx, | ||
793 | 86 | int minfy, | ||
794 | 87 | int maxfy); | ||
795 | 98 | 88 | ||
796 | 99 | DISALLOW_COPY_AND_ASSIGN(GameRenderer); | 89 | DISALLOW_COPY_AND_ASSIGN(GameRenderer); |
797 | 100 | }; | 90 | }; |
798 | 101 | 91 | ||
799 | === removed file 'src/graphic/gl/game_renderer.cc' | |||
800 | --- src/graphic/gl/game_renderer.cc 2014-11-28 05:40:53 +0000 | |||
801 | +++ src/graphic/gl/game_renderer.cc 1970-01-01 00:00:00 +0000 | |||
802 | @@ -1,191 +0,0 @@ | |||
803 | 1 | /* | ||
804 | 2 | * Copyright (C) 2011-2013 by the Widelands Development Team | ||
805 | 3 | * | ||
806 | 4 | * This program is free software; you can redistribute it and/or | ||
807 | 5 | * modify it under the terms of the GNU General Public License | ||
808 | 6 | * as published by the Free Software Foundation; either version 2 | ||
809 | 7 | * of the License, or (at your option) any later version. | ||
810 | 8 | * | ||
811 | 9 | * This program is distributed in the hope that it will be useful, | ||
812 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
813 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
814 | 12 | * GNU General Public License for more details. | ||
815 | 13 | * | ||
816 | 14 | * You should have received a copy of the GNU General Public License | ||
817 | 15 | * along with this program; if not, write to the Free Software | ||
818 | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
819 | 17 | * | ||
820 | 18 | */ | ||
821 | 19 | |||
822 | 20 | #include "graphic/gl/game_renderer.h" | ||
823 | 21 | |||
824 | 22 | #include <memory> | ||
825 | 23 | |||
826 | 24 | #include "graphic/gl/dither_program.h" | ||
827 | 25 | #include "graphic/gl/fields_to_draw.h" | ||
828 | 26 | #include "graphic/gl/road_program.h" | ||
829 | 27 | #include "graphic/gl/terrain_program.h" | ||
830 | 28 | #include "graphic/graphic.h" | ||
831 | 29 | #include "graphic/rendertarget.h" | ||
832 | 30 | #include "graphic/surface.h" | ||
833 | 31 | #include "logic/editor_game_base.h" | ||
834 | 32 | #include "logic/player.h" | ||
835 | 33 | #include "logic/world/world.h" | ||
836 | 34 | #include "wui/mapviewpixelconstants.h" | ||
837 | 35 | #include "wui/mapviewpixelfunctions.h" | ||
838 | 36 | #include "wui/overlay_manager.h" | ||
839 | 37 | |||
840 | 38 | namespace { | ||
841 | 39 | |||
842 | 40 | using namespace Widelands; | ||
843 | 41 | |||
844 | 42 | // Returns the brightness value in [0, 1.] for 'fcoords' at 'gametime' for | ||
845 | 43 | // 'player' (which can be nullptr). | ||
846 | 44 | float field_brightness(const FCoords& fcoords, | ||
847 | 45 | const uint32_t gametime, | ||
848 | 46 | const Map& map, | ||
849 | 47 | const Player* const player) { | ||
850 | 48 | uint32_t brightness = 144 + fcoords.field->get_brightness(); | ||
851 | 49 | brightness = std::min<uint32_t>(255, (brightness * 255) / 160); | ||
852 | 50 | |||
853 | 51 | if (player && !player->see_all()) { | ||
854 | 52 | const Player::Field& pf = player->fields()[Map::get_index(fcoords, map.get_width())]; | ||
855 | 53 | if (pf.vision == 0) { | ||
856 | 54 | return 0.; | ||
857 | 55 | } else if (pf.vision == 1) { | ||
858 | 56 | static const uint32_t kDecayTimeInMs = 20000; | ||
859 | 57 | const Duration time_ago = gametime - pf.time_node_last_unseen; | ||
860 | 58 | if (time_ago < kDecayTimeInMs) { | ||
861 | 59 | brightness = (brightness * (2 * kDecayTimeInMs - time_ago)) / (2 * kDecayTimeInMs); | ||
862 | 60 | } else { | ||
863 | 61 | brightness = brightness / 2; | ||
864 | 62 | } | ||
865 | 63 | } | ||
866 | 64 | } | ||
867 | 65 | return brightness / 255.; | ||
868 | 66 | } | ||
869 | 67 | |||
870 | 68 | // Returns the road that should be rendered here. The format is like in field, | ||
871 | 69 | // but this is not the physically present road, but the one that should be | ||
872 | 70 | // drawn (i.e. taking into account if there is fog of war involved or road | ||
873 | 71 | // building overlays enabled). | ||
874 | 72 | uint8_t field_roads(const FCoords& coords, const Map& map, const Player* const player) { | ||
875 | 73 | uint8_t roads; | ||
876 | 74 | if (player && !player->see_all()) { | ||
877 | 75 | const Player::Field& pf = player->fields()[Map::get_index(coords, map.get_width())]; | ||
878 | 76 | roads = pf.roads | map.overlay_manager().get_road_overlay(coords); | ||
879 | 77 | } else { | ||
880 | 78 | roads = coords.field->get_roads(); | ||
881 | 79 | } | ||
882 | 80 | roads |= map.overlay_manager().get_road_overlay(coords); | ||
883 | 81 | return roads; | ||
884 | 82 | } | ||
885 | 83 | |||
886 | 84 | } // namespace | ||
887 | 85 | |||
888 | 86 | // Explanation of how drawing works: | ||
889 | 87 | // Schematic of triangle neighborhood: | ||
890 | 88 | // | ||
891 | 89 | // * | ||
892 | 90 | // / \ | ||
893 | 91 | // / u \ | ||
894 | 92 | // (f)/ \ | ||
895 | 93 | // *------*------* (r) | ||
896 | 94 | // \ l / \ r / \ | ||
897 | 95 | // \ / \ / \ | ||
898 | 96 | // \/ d \/ rr \ | ||
899 | 97 | // *------*------* (br) | ||
900 | 98 | // \ dd / | ||
901 | 99 | // \ / | ||
902 | 100 | // \/ | ||
903 | 101 | // * | ||
904 | 102 | // | ||
905 | 103 | // Each field (f) owns two triangles: (r)ight & (d)own. When we look at the | ||
906 | 104 | // field, we have to make sure to schedule drawing the triangles. This is done | ||
907 | 105 | // by of these triangles is done by TerrainProgram. | ||
908 | 106 | // | ||
909 | 107 | // To draw dithered edges, we have to look at the neighboring triangles for the | ||
910 | 108 | // two triangles too: If a neighboring triangle has another texture and our | ||
911 | 109 | // dither layer is smaller, we have to draw a dithering triangle too - this lets the neighboring | ||
912 | 110 | // texture | ||
913 | 111 | // bleed into our triangle. | ||
914 | 112 | // | ||
915 | 113 | // The dither triangle is the triangle that should be partially (either r or | ||
916 | 114 | // d). Example: if r and d have different textures and r.dither_layer > | ||
917 | 115 | // d.dither_layer, then we will repaint d with the dither texture as mask. | ||
918 | 116 | |||
919 | 117 | |||
920 | 118 | std::unique_ptr<TerrainProgram> GlGameRenderer::terrain_program_; | ||
921 | 119 | std::unique_ptr<DitherProgram> GlGameRenderer::dither_program_; | ||
922 | 120 | std::unique_ptr<RoadProgram> GlGameRenderer::road_program_; | ||
923 | 121 | |||
924 | 122 | GlGameRenderer::GlGameRenderer() { | ||
925 | 123 | } | ||
926 | 124 | |||
927 | 125 | GlGameRenderer::~GlGameRenderer() { | ||
928 | 126 | } | ||
929 | 127 | |||
930 | 128 | void GlGameRenderer::draw() { | ||
931 | 129 | if (terrain_program_ == nullptr) { | ||
932 | 130 | terrain_program_.reset(new TerrainProgram()); | ||
933 | 131 | dither_program_.reset(new DitherProgram()); | ||
934 | 132 | road_program_.reset(new RoadProgram()); | ||
935 | 133 | } | ||
936 | 134 | |||
937 | 135 | Surface* surface = m_dst->get_surface(); | ||
938 | 136 | if (!surface) | ||
939 | 137 | return; | ||
940 | 138 | |||
941 | 139 | const Rect& bounding_rect = m_dst->get_rect(); | ||
942 | 140 | const Point surface_offset = m_dst_offset + bounding_rect.top_left() + m_dst->get_offset(); | ||
943 | 141 | |||
944 | 142 | glScissor(bounding_rect.x, | ||
945 | 143 | surface->height() - bounding_rect.y - bounding_rect.h, | ||
946 | 144 | bounding_rect.w, | ||
947 | 145 | bounding_rect.h); | ||
948 | 146 | glEnable(GL_SCISSOR_TEST); | ||
949 | 147 | |||
950 | 148 | Map& map = m_egbase->map(); | ||
951 | 149 | const uint32_t gametime = m_egbase->get_gametime(); | ||
952 | 150 | |||
953 | 151 | FieldsToDraw fields_to_draw(m_minfx, m_maxfx, m_minfy, m_maxfy); | ||
954 | 152 | for (int32_t fy = m_minfy; fy <= m_maxfy; ++fy) { | ||
955 | 153 | for (int32_t fx = m_minfx; fx <= m_maxfx; ++fx) { | ||
956 | 154 | FieldsToDraw::Field& f = | ||
957 | 155 | *fields_to_draw.mutable_field(fields_to_draw.calculate_index(fx, fy)); | ||
958 | 156 | |||
959 | 157 | f.fx = fx; | ||
960 | 158 | f.fy = fy; | ||
961 | 159 | |||
962 | 160 | Coords coords(fx, fy); | ||
963 | 161 | int x, y; | ||
964 | 162 | MapviewPixelFunctions::get_basepix(coords, x, y); | ||
965 | 163 | |||
966 | 164 | map.normalize_coords(coords); | ||
967 | 165 | const FCoords& fcoords = map.get_fcoords(coords); | ||
968 | 166 | |||
969 | 167 | f.texture_x = float(x) / kTextureSideLength; | ||
970 | 168 | f.texture_y = float(y) / kTextureSideLength; | ||
971 | 169 | |||
972 | 170 | f.gl_x = f.pixel_x = x + surface_offset.x; | ||
973 | 171 | f.gl_y = f.pixel_y = y + surface_offset.y - fcoords.field->get_height() * HEIGHT_FACTOR; | ||
974 | 172 | surface->pixel_to_gl(&f.gl_x, &f.gl_y); | ||
975 | 173 | |||
976 | 174 | f.ter_d = fcoords.field->terrain_d(); | ||
977 | 175 | f.ter_r = fcoords.field->terrain_r(); | ||
978 | 176 | |||
979 | 177 | f.brightness = field_brightness(fcoords, gametime, map, m_player); | ||
980 | 178 | |||
981 | 179 | f.roads = field_roads(fcoords, map, m_player); | ||
982 | 180 | } | ||
983 | 181 | } | ||
984 | 182 | |||
985 | 183 | const World& world = m_egbase->world(); | ||
986 | 184 | terrain_program_->draw(gametime, world.terrains(), fields_to_draw); | ||
987 | 185 | dither_program_->draw(gametime, world.terrains(), fields_to_draw); | ||
988 | 186 | road_program_->draw(*surface, fields_to_draw); | ||
989 | 187 | |||
990 | 188 | draw_objects(); | ||
991 | 189 | |||
992 | 190 | glDisable(GL_SCISSOR_TEST); | ||
993 | 191 | } | ||
994 | 192 | 0 | ||
995 | === removed file 'src/graphic/gl/game_renderer.h' | |||
996 | --- src/graphic/gl/game_renderer.h 2014-11-01 20:40:39 +0000 | |||
997 | +++ src/graphic/gl/game_renderer.h 1970-01-01 00:00:00 +0000 | |||
998 | @@ -1,48 +0,0 @@ | |||
999 | 1 | /* | ||
1000 | 2 | * Copyright (C) 2011-2013 by the Widelands Development Team | ||
1001 | 3 | * | ||
1002 | 4 | * This program is free software; you can redistribute it and/or | ||
1003 | 5 | * modify it under the terms of the GNU General Public License | ||
1004 | 6 | * as published by the Free Software Foundation; either version 2 | ||
1005 | 7 | * of the License, or (at your option) any later version. | ||
1006 | 8 | * | ||
1007 | 9 | * This program is distributed in the hope that it will be useful, | ||
1008 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1009 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1010 | 12 | * GNU General Public License for more details. | ||
1011 | 13 | * | ||
1012 | 14 | * You should have received a copy of the GNU General Public License | ||
1013 | 15 | * along with this program; if not, write to the Free Software | ||
1014 | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
1015 | 17 | * | ||
1016 | 18 | */ | ||
1017 | 19 | |||
1018 | 20 | #ifndef WL_GRAPHIC_GL_GAME_RENDERER_H | ||
1019 | 21 | #define WL_GRAPHIC_GL_GAME_RENDERER_H | ||
1020 | 22 | |||
1021 | 23 | #include <memory> | ||
1022 | 24 | |||
1023 | 25 | #include "graphic/game_renderer.h" | ||
1024 | 26 | #include "graphic/gl/utils.h" | ||
1025 | 27 | |||
1026 | 28 | class TerrainProgram; | ||
1027 | 29 | class DitherProgram; | ||
1028 | 30 | class RoadProgram; | ||
1029 | 31 | |||
1030 | 32 | /** | ||
1031 | 33 | * OpenGL implementation of @ref GameRenderer. | ||
1032 | 34 | */ | ||
1033 | 35 | class GlGameRenderer : public GameRenderer { | ||
1034 | 36 | public: | ||
1035 | 37 | GlGameRenderer(); | ||
1036 | 38 | virtual ~GlGameRenderer(); | ||
1037 | 39 | |||
1038 | 40 | private: | ||
1039 | 41 | static std::unique_ptr<TerrainProgram> terrain_program_; | ||
1040 | 42 | static std::unique_ptr<DitherProgram> dither_program_; | ||
1041 | 43 | static std::unique_ptr<RoadProgram> road_program_; | ||
1042 | 44 | |||
1043 | 45 | void draw() override; | ||
1044 | 46 | }; | ||
1045 | 47 | |||
1046 | 48 | #endif // end of include guard: WL_GRAPHIC_GL_GAME_RENDERER_H | ||
1047 | 49 | 0 | ||
1048 | === modified file 'src/graphic/rendertarget.cc' | |||
1049 | --- src/graphic/rendertarget.cc 2014-12-02 19:00:52 +0000 | |||
1050 | +++ src/graphic/rendertarget.cc 2014-12-04 20:54:56 +0000 | |||
1051 | @@ -27,7 +27,6 @@ | |||
1052 | 27 | #include "graphic/surface.h" | 27 | #include "graphic/surface.h" |
1053 | 28 | #include "logic/player.h" | 28 | #include "logic/player.h" |
1054 | 29 | #include "logic/tribe.h" | 29 | #include "logic/tribe.h" |
1055 | 30 | #include "wui/mapviewpixelconstants.h" | ||
1056 | 31 | #include "wui/overlay_manager.h" | 30 | #include "wui/overlay_manager.h" |
1057 | 32 | 31 | ||
1058 | 33 | using Widelands::BaseImmovable; | 32 | using Widelands::BaseImmovable; |
1059 | 34 | 33 | ||
1060 | === modified file 'src/logic/CMakeLists.txt' | |||
1061 | --- src/logic/CMakeLists.txt 2014-12-01 21:28:21 +0000 | |||
1062 | +++ src/logic/CMakeLists.txt 2014-12-04 20:54:56 +0000 | |||
1063 | @@ -6,6 +6,7 @@ | |||
1064 | 6 | base_log | 6 | base_log |
1065 | 7 | graphic | 7 | graphic |
1066 | 8 | graphic_image_io | 8 | graphic_image_io |
1067 | 9 | graphic_minimap_renderer | ||
1068 | 9 | graphic_surface | 10 | graphic_surface |
1069 | 10 | io_fileread | 11 | io_fileread |
1070 | 11 | io_filesystem | 12 | io_filesystem |
1071 | @@ -250,5 +251,7 @@ | |||
1072 | 250 | ui_basic | 251 | ui_basic |
1073 | 251 | widelands_ball_of_mud | 252 | widelands_ball_of_mud |
1074 | 252 | wui | 253 | wui |
1075 | 254 | wui_mapview_pixelfunctions | ||
1076 | 255 | wui_overlay_manager | ||
1077 | 253 | wui_text_layout | 256 | wui_text_layout |
1078 | 254 | ) | 257 | ) |
1079 | 255 | 258 | ||
1080 | === modified file 'src/map_io/CMakeLists.txt' | |||
1081 | --- src/map_io/CMakeLists.txt 2014-12-01 21:31:00 +0000 | |||
1082 | +++ src/map_io/CMakeLists.txt 2014-12-04 20:54:56 +0000 | |||
1083 | @@ -93,6 +93,7 @@ | |||
1084 | 93 | economy | 93 | economy |
1085 | 94 | graphic | 94 | graphic |
1086 | 95 | graphic_image_io | 95 | graphic_image_io |
1087 | 96 | graphic_minimap_renderer | ||
1088 | 96 | graphic_surface | 97 | graphic_surface |
1089 | 97 | helper | 98 | helper |
1090 | 98 | io_fileread | 99 | io_fileread |
1091 | 99 | 100 | ||
1092 | === modified file 'src/scripting/CMakeLists.txt' | |||
1093 | --- src/scripting/CMakeLists.txt 2014-11-28 16:40:55 +0000 | |||
1094 | +++ src/scripting/CMakeLists.txt 2014-12-04 20:54:56 +0000 | |||
1095 | @@ -57,4 +57,5 @@ | |||
1096 | 57 | third_party_eris | 57 | third_party_eris |
1097 | 58 | ui_basic | 58 | ui_basic |
1098 | 59 | wui | 59 | wui |
1099 | 60 | wui_mapview_pixelfunctions | ||
1100 | 60 | ) | 61 | ) |
1101 | 61 | 62 | ||
1102 | === modified file 'src/sound/CMakeLists.txt' | |||
1103 | --- src/sound/CMakeLists.txt 2014-11-28 16:40:55 +0000 | |||
1104 | +++ src/sound/CMakeLists.txt 2014-12-04 20:54:56 +0000 | |||
1105 | @@ -21,4 +21,5 @@ | |||
1106 | 21 | profile | 21 | profile |
1107 | 22 | random | 22 | random |
1108 | 23 | wui | 23 | wui |
1109 | 24 | wui_mapview_pixelfunctions | ||
1110 | 24 | ) | 25 | ) |
1111 | 25 | 26 | ||
1112 | === modified file 'src/wui/CMakeLists.txt' | |||
1113 | --- src/wui/CMakeLists.txt 2014-11-28 16:40:55 +0000 | |||
1114 | +++ src/wui/CMakeLists.txt 2014-12-04 20:54:56 +0000 | |||
1115 | @@ -29,6 +29,29 @@ | |||
1116 | 29 | wui | 29 | wui |
1117 | 30 | ) | 30 | ) |
1118 | 31 | 31 | ||
1119 | 32 | wl_library(wui_overlay_manager | ||
1120 | 33 | SRCS | ||
1121 | 34 | overlay_manager.cc | ||
1122 | 35 | overlay_manager.h | ||
1123 | 36 | DEPENDS | ||
1124 | 37 | base_geometry | ||
1125 | 38 | graphic | ||
1126 | 39 | logic | ||
1127 | 40 | logic_widelands_geometry | ||
1128 | 41 | ) | ||
1129 | 42 | |||
1130 | 43 | wl_library(wui_mapview_pixelfunctions | ||
1131 | 44 | SRCS | ||
1132 | 45 | mapviewpixelconstants.h | ||
1133 | 46 | mapviewpixelfunctions.cc | ||
1134 | 47 | mapviewpixelfunctions.h | ||
1135 | 48 | vector.h | ||
1136 | 49 | DEPENDS | ||
1137 | 50 | base_geometry | ||
1138 | 51 | logic | ||
1139 | 52 | logic_widelands_geometry | ||
1140 | 53 | ) | ||
1141 | 54 | |||
1142 | 32 | wl_library(wui | 55 | wl_library(wui |
1143 | 33 | SRCS | 56 | SRCS |
1144 | 34 | actionconfirm.cc | 57 | actionconfirm.cc |
1145 | @@ -83,16 +106,11 @@ | |||
1146 | 83 | logmessage.h | 106 | logmessage.h |
1147 | 84 | mapview.cc | 107 | mapview.cc |
1148 | 85 | mapview.h | 108 | mapview.h |
1149 | 86 | mapviewpixelconstants.h | ||
1150 | 87 | mapviewpixelfunctions.cc | ||
1151 | 88 | mapviewpixelfunctions.h | ||
1152 | 89 | militarysitewindow.cc | 109 | militarysitewindow.cc |
1153 | 90 | minimap.cc | 110 | minimap.cc |
1154 | 91 | minimap.h | 111 | minimap.h |
1155 | 92 | multiplayersetupgroup.cc | 112 | multiplayersetupgroup.cc |
1156 | 93 | multiplayersetupgroup.h | 113 | multiplayersetupgroup.h |
1157 | 94 | overlay_manager.cc | ||
1158 | 95 | overlay_manager.h | ||
1159 | 96 | playerdescrgroup.cc | 114 | playerdescrgroup.cc |
1160 | 97 | playerdescrgroup.h | 115 | playerdescrgroup.h |
1161 | 98 | plot_area.cc | 116 | plot_area.cc |
1162 | @@ -117,7 +135,6 @@ | |||
1163 | 117 | transport_ui.cc | 135 | transport_ui.cc |
1164 | 118 | unique_window_handler.cc | 136 | unique_window_handler.cc |
1165 | 119 | unique_window_handler.h | 137 | unique_window_handler.h |
1166 | 120 | vector.h | ||
1167 | 121 | ware_statistics_menu.cc | 138 | ware_statistics_menu.cc |
1168 | 122 | ware_statistics_menu.h | 139 | ware_statistics_menu.h |
1169 | 123 | warehousewindow.cc | 140 | warehousewindow.cc |
1170 | @@ -140,7 +157,9 @@ | |||
1171 | 140 | game_io | 157 | game_io |
1172 | 141 | graphic | 158 | graphic |
1173 | 142 | graphic_color | 159 | graphic_color |
1174 | 160 | graphic_game_renderer | ||
1175 | 143 | graphic_image | 161 | graphic_image |
1176 | 162 | graphic_minimap_renderer | ||
1177 | 144 | graphic_surface | 163 | graphic_surface |
1178 | 145 | io_fileread | 164 | io_fileread |
1179 | 146 | io_filesystem | 165 | io_filesystem |
1180 | @@ -157,5 +176,7 @@ | |||
1181 | 157 | ui_fsmenu | 176 | ui_fsmenu |
1182 | 158 | widelands_ball_of_mud | 177 | widelands_ball_of_mud |
1183 | 159 | wui_chat_ui | 178 | wui_chat_ui |
1184 | 179 | wui_mapview_pixelfunctions | ||
1185 | 180 | wui_overlay_manager | ||
1186 | 160 | wui_text_layout | 181 | wui_text_layout |
1187 | 161 | ) | 182 | ) |
1188 | 162 | 183 | ||
1189 | === modified file 'src/wui/mapview.cc' | |||
1190 | --- src/wui/mapview.cc 2014-11-22 18:36:33 +0000 | |||
1191 | +++ src/wui/mapview.cc 2014-12-04 20:54:56 +0000 | |||
1192 | @@ -20,7 +20,7 @@ | |||
1193 | 20 | #include "wui/mapview.h" | 20 | #include "wui/mapview.h" |
1194 | 21 | 21 | ||
1195 | 22 | #include "base/macros.h" | 22 | #include "base/macros.h" |
1197 | 23 | #include "graphic/gl/game_renderer.h" | 23 | #include "graphic/game_renderer.h" |
1198 | 24 | #include "graphic/graphic.h" | 24 | #include "graphic/graphic.h" |
1199 | 25 | #include "graphic/rendertarget.h" | 25 | #include "graphic/rendertarget.h" |
1200 | 26 | #include "logic/map.h" | 26 | #include "logic/map.h" |
1201 | @@ -31,16 +31,14 @@ | |||
1202 | 31 | #include "wui/mapviewpixelfunctions.h" | 31 | #include "wui/mapviewpixelfunctions.h" |
1203 | 32 | #include "wui/overlay_manager.h" | 32 | #include "wui/overlay_manager.h" |
1204 | 33 | 33 | ||
1215 | 34 | MapView::MapView | 34 | MapView::MapView( |
1216 | 35 | (UI::Panel * parent, | 35 | UI::Panel* parent, int32_t x, int32_t y, uint32_t w, uint32_t h, InteractiveBase& player) |
1217 | 36 | int32_t x, int32_t y, uint32_t w, uint32_t h, | 36 | : UI::Panel(parent, x, y, w, h), |
1218 | 37 | InteractiveBase & player) | 37 | m_renderer(new GameRenderer()), |
1219 | 38 | : | 38 | m_intbase(player), |
1220 | 39 | UI::Panel (parent, x, y, w, h), | 39 | m_viewpoint(Point(0, 0)), |
1221 | 40 | m_intbase (player), | 40 | m_dragging(false) { |
1222 | 41 | m_viewpoint (Point(0, 0)), | 41 | } |
1213 | 42 | m_dragging (false) | ||
1214 | 43 | {} | ||
1223 | 44 | 42 | ||
1224 | 45 | MapView::~MapView() | 43 | MapView::~MapView() |
1225 | 46 | { | 44 | { |
1226 | @@ -90,11 +88,8 @@ | |||
1227 | 90 | 88 | ||
1228 | 91 | egbase.map().overlay_manager().load_graphics(); | 89 | egbase.map().overlay_manager().load_graphics(); |
1229 | 92 | 90 | ||
1230 | 93 | if (!m_renderer) { | ||
1231 | 94 | m_renderer.reset(new GlGameRenderer()); | ||
1232 | 95 | } | ||
1233 | 96 | if (upcast(InteractivePlayer const, interactive_player, &intbase())) { | 91 | if (upcast(InteractivePlayer const, interactive_player, &intbase())) { |
1235 | 97 | m_renderer->rendermap(dst, egbase, interactive_player->player(), m_viewpoint); | 92 | m_renderer->rendermap(dst, egbase, m_viewpoint, interactive_player->player()); |
1236 | 98 | } else { | 93 | } else { |
1237 | 99 | m_renderer->rendermap(dst, egbase, m_viewpoint); | 94 | m_renderer->rendermap(dst, egbase, m_viewpoint); |
1238 | 100 | } | 95 | } |
global? general? wl-lib? common? core? root? shared?
While we're restructuring, should we separate wl/game and wl/editor?