Status: | Merged | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 6242 | ||||||||||||||||||||
Proposed branch: | lp:~shevonar/widelands/opengl | ||||||||||||||||||||
Merge into: | lp:widelands | ||||||||||||||||||||
Diff against target: |
1106 lines (+541/-129) 16 files modified
ChangeLog (+7/-1) src/graphic/graphic.cc (+20/-4) src/graphic/graphic.h (+3/-1) src/graphic/render/gameview.cc (+12/-79) src/graphic/render/gameview.h (+6/-6) src/graphic/render/gameview_opengl.cc (+101/-0) src/graphic/render/gameview_opengl.h (+54/-0) src/graphic/render/gameview_sdl.cc (+105/-0) src/graphic/render/gameview_sdl.h (+50/-0) src/graphic/render/terrain_opengl.h (+130/-19) src/graphic/texture.cc (+31/-6) src/graphic/texture.h (+2/-2) src/ui_fsmenu/options.cc (+3/-3) src/wlapplication.cc (+7/-4) src/wui/mapview.cc (+10/-3) worlds/greenland/terrainconf (+0/-1) |
||||||||||||||||||||
To merge this branch: | bzr merge lp:~shevonar/widelands/opengl | ||||||||||||||||||||
Related bugs: |
|
||||||||||||||||||||
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Widelands Developers | Pending | ||
Review via email: mp+93852@code.launchpad.net |
Commit message
Description of the change
This branch improves the OpenGL rendering:
- gameview is split into two subclasses: gameviewSDL and gameviewOpenGL
- terrain edges are dithered and rounded in OpenGL mode (via a texture mask)
- minimap is shaded correctly
- road textures should be fixed (resized to 64x64px)
- Made OpenGL the standard renderer and remove * highly experimental * from options menu
- fixed bug 649037
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2012-02-07 14:43:41 +0000 |
3 | +++ ChangeLog 2012-02-20 16:00:42 +0000 |
4 | @@ -12,6 +12,7 @@ |
5 | - Improved a lot of icons and button appearence. |
6 | - Improved statistics window. |
7 | - Improved the Widelands code to use less resources. |
8 | +- Improved OpenGL rendering which is now active by default. |
9 | - Added a new piece of music to Widelands |
10 | - Added new states and animations for unoccupied buildings and empty mines, |
11 | to better indicate the current state of a building. |
12 | @@ -35,14 +36,16 @@ |
13 | - Fixed a bug that disallowed to connect to different servers (via |
14 | metaserver) without prior restart of Widelands. |
15 | - (Re)Fixed bug #536149: miner/master miner mixed up after enhancing |
16 | - to deep mine. |
17 | + to deep mine. |
18 | - Fixed bug #565406: focus for save window |
19 | - Fixed bug #570055: Open house window on doubleclick even when minimized |
20 | - Fixed bug #590528: add more details to a replay |
21 | - Fixed bug #590631: All workers die, when warehouse/hq is destroyed |
22 | +- Fixed bug #594686: Roads not rendered correctly in opengl mode on some systems |
23 | - Fixed bug #601400: Request::get_base_required_time:WARNING nr = 1 but |
24 | count is 1, which is not allowed according to the |
25 | comment for this function |
26 | +- Fixed bug #649037: Many menus are not repainted in OpenGL mode |
27 | - Fixed bug #657266: Unoccupied helmsmithy animation contains a person |
28 | - Fixed bug #672085: New stock menu layout too high for small resolutions |
29 | - Fixed bug #672098: The priority buttons can be deactivated |
30 | @@ -50,7 +53,9 @@ |
31 | - Fixed bug #691928: Message icon is not updated in some cases when |
32 | receiving focus |
33 | - Fixed bug #695035: Adjusted hotspots of buildings to fit into their space |
34 | +- Fixed bug #722196: OpenGL terrain renderer does not dither between adjacent fields |
35 | - Fixed bug #722793: Ducks on land on Three Warriors |
36 | +- Fixed bug #722796: Minimap not shaded by terrain height in OpenGL |
37 | - Fixed bug #723112: The name is not shown for resource coal in the |
38 | resource dialog in the editor |
39 | - Fixed bug #726699: Make the wares priority buttons in production sites |
40 | @@ -99,6 +104,7 @@ |
41 | - Fixed bug #886493: Default AI is set to none |
42 | - Fixed bug #886572: After a while, increasing game speed makes the game |
43 | lag even at lower speeds |
44 | +- Fixed bug #887093: Make OpenGL the standard renderer |
45 | - Fixed bug #902765: Show buttons in the bottom toolbar in the same |
46 | order, also for spectators |
47 | - Fixed bug #902823: Show "increase/decrease capacity" buttons only |
48 | |
49 | === modified file 'src/graphic/graphic.cc' |
50 | --- src/graphic/graphic.cc 2012-02-19 17:10:12 +0000 |
51 | +++ src/graphic/graphic.cc 2012-02-20 16:00:42 +0000 |
52 | @@ -1,5 +1,5 @@ |
53 | /* |
54 | - * Copyright (C) 2002-2004, 2006-2011 by the Widelands Development Team |
55 | + * Copyright (C) 2002-2004, 2006-2012 by the Widelands Development Team |
56 | * |
57 | * This program is free software; you can redistribute it and/or |
58 | * modify it under the terms of the GNU General Public License |
59 | @@ -1034,8 +1034,9 @@ |
60 | */ |
61 | void Graphic::animate_maptextures(uint32_t time) |
62 | { |
63 | - for (uint32_t i = 0; i < m_maptextures.size(); ++i) |
64 | + for (uint32_t i = 0; i < m_maptextures.size(); ++i) { |
65 | m_maptextures[i]->animate(time); |
66 | + } |
67 | } |
68 | |
69 | /** |
70 | @@ -1043,8 +1044,9 @@ |
71 | */ |
72 | void Graphic::reset_texture_animation_reminder() |
73 | { |
74 | - for (uint32_t i = 0; i < m_maptextures.size(); ++i) |
75 | + for (uint32_t i = 0; i < m_maptextures.size(); ++i) { |
76 | m_maptextures[i]->reset_was_animated(); |
77 | + } |
78 | } |
79 | |
80 | /** |
81 | @@ -1164,8 +1166,9 @@ |
82 | return 0; |
83 | } |
84 | |
85 | + |
86 | /** |
87 | - * Sets the name of the current world and loads the fitting road textures |
88 | + * Sets the name of the current world and loads the fitting road and edge textures |
89 | */ |
90 | void Graphic::set_world(std::string worldname) { |
91 | char buf[255]; |
92 | @@ -1179,6 +1182,10 @@ |
93 | m_roadtextures->pic_road_normal = get_picture(PicMod_Game, buf, false); |
94 | snprintf(buf, sizeof(buf), "worlds/%s/pics/roadt_busy.png", worldname.c_str()); |
95 | m_roadtextures->pic_road_busy = get_picture(PicMod_Game, buf, false); |
96 | + |
97 | + // load edge texture |
98 | + snprintf(buf, sizeof(buf), "worlds/%s/pics/edge.png", worldname.c_str()); |
99 | + m_edgetexture = get_picture(PicMod_Game, buf, false); |
100 | } |
101 | |
102 | /** |
103 | @@ -1191,3 +1198,12 @@ |
104 | return |
105 | (roadtex == Widelands::Road_Normal ? m_roadtextures->pic_road_normal : m_roadtextures->pic_road_busy); |
106 | } |
107 | + |
108 | +/** |
109 | + * Returns the alpha mask texture for edges. |
110 | + * \return The edge texture (alpha mask) |
111 | + */ |
112 | +PictureID Graphic::get_edge_texture() |
113 | +{ |
114 | + return m_edgetexture; |
115 | +} |
116 | |
117 | === modified file 'src/graphic/graphic.h' |
118 | --- src/graphic/graphic.h 2011-11-30 21:38:37 +0000 |
119 | +++ src/graphic/graphic.h 2012-02-20 16:00:42 +0000 |
120 | @@ -1,5 +1,5 @@ |
121 | /* |
122 | - * Copyright (C) 2002-2004, 2006-2011 by the Widelands Development Team |
123 | + * Copyright (C) 2002-2004, 2006-2012 by the Widelands Development Team |
124 | * |
125 | * This program is free software; you can redistribute it and/or |
126 | * modify it under the terms of the GNU General Public License |
127 | @@ -189,6 +189,7 @@ |
128 | |
129 | void set_world(std::string); |
130 | PictureID get_road_texture(int32_t roadtex); |
131 | + PictureID get_edge_texture(); |
132 | |
133 | GraphicCaps const & caps() const throw () {return m_caps;} |
134 | |
135 | @@ -236,6 +237,7 @@ |
136 | Picturemap m_picturemap; |
137 | |
138 | Road_Textures * m_roadtextures; |
139 | + PictureID m_edgetexture; |
140 | std::vector<Texture *> m_maptextures; |
141 | std::vector<AnimationGfx *> m_animations; |
142 | }; |
143 | |
144 | === modified file 'src/graphic/render/gameview.cc' |
145 | --- src/graphic/render/gameview.cc 2012-02-12 17:17:26 +0000 |
146 | +++ src/graphic/render/gameview.cc 2012-02-20 16:00:42 +0000 |
147 | @@ -1,5 +1,5 @@ |
148 | /* |
149 | - * Copyright (C) 2010-2011 by the Widelands Development Team |
150 | + * Copyright (C) 2010-2012 by the Widelands Development Team |
151 | * |
152 | * This program is free software; you can redistribute it and/or |
153 | * modify it under the terms of the GNU General Public License |
154 | @@ -39,7 +39,6 @@ |
155 | #include "wui/overlay_manager.h" |
156 | |
157 | #include "terrain_sdl.h" |
158 | -#include "terrain_opengl.h" |
159 | |
160 | using Widelands::BaseImmovable; |
161 | using Widelands::Coords; |
162 | @@ -214,8 +213,10 @@ |
163 | f_vert.tx += TRIANGLE_WIDTH / 2; |
164 | r_vert.tx += TRIANGLE_WIDTH / 2; |
165 | } else { |
166 | - bl_vert.tx -= TRIANGLE_WIDTH / 2; |
167 | - br_vert.tx -= TRIANGLE_WIDTH / 2; |
168 | + f_vert.tx += TRIANGLE_WIDTH; |
169 | + r_vert.tx += TRIANGLE_WIDTH; |
170 | + bl_vert.tx += TRIANGLE_WIDTH / 2; |
171 | + br_vert.tx += TRIANGLE_WIDTH / 2; |
172 | } |
173 | |
174 | draw_field // Render ground |
175 | @@ -986,16 +987,16 @@ |
176 | * into the bitmap. |
177 | * |
178 | * Vertices: |
179 | - * - f_vert vertice of the field |
180 | - * - r_vert vertice right of the field |
181 | - * - bl_vert vertice bottom left of the field |
182 | - * - br_vert vertice bottom right of the field |
183 | + * - f_vert vertex of the field |
184 | + * - r_vert vertex right of the field |
185 | + * - bl_vert vertex bottom left of the field |
186 | + * - br_vert vertex bottom right of the field |
187 | * |
188 | * Textures: |
189 | * - f_r_texture Terrain of the triangle right of the field |
190 | * - f_d_texture Terrain of the triangle under of the field |
191 | - * - tr_d_texture Terrain of the triangle to of the right triangle ?? |
192 | - * - l_r_texture Terrain of the triangle left if the down triangle ?? |
193 | + * - tr_d_texture Terrain of the triangle top of the right triangle ?? |
194 | + * - l_r_texture Terrain of the triangle left of the down triangle ?? |
195 | * |
196 | * (tr_d) |
197 | * |
198 | @@ -1018,43 +1019,7 @@ |
199 | Texture const & f_d_texture, |
200 | Texture const & f_r_texture) |
201 | { |
202 | - upcast(SurfaceSDL, sdlsurf, m_surface.get()); |
203 | - if (sdlsurf) |
204 | - { |
205 | - sdlsurf->set_subwin(subwin); |
206 | - switch (sdlsurf->format().BytesPerPixel) { |
207 | - case 2: |
208 | - draw_field_int<Uint16> |
209 | - (*sdlsurf, |
210 | - f_vert, r_vert, bl_vert, br_vert, |
211 | - roads, |
212 | - tr_d_texture, l_r_texture, f_d_texture, f_r_texture); |
213 | - break; |
214 | - case 4: |
215 | - draw_field_int<Uint32> |
216 | - (*sdlsurf, |
217 | - f_vert, r_vert, bl_vert, br_vert, |
218 | - roads, |
219 | - tr_d_texture, l_r_texture, f_d_texture, f_r_texture); |
220 | - break; |
221 | - default: |
222 | - assert(false); |
223 | - } |
224 | - sdlsurf->unset_subwin(); |
225 | - } |
226 | -#ifdef USE_OPENGL |
227 | - else |
228 | - { |
229 | - // Draw triangle right (bottom) of the field |
230 | - draw_field_opengl |
231 | - (subwin, f_vert, br_vert, r_vert, f_r_texture); |
232 | - // Draw triangle bottom of the field |
233 | - draw_field_opengl |
234 | - (subwin, f_vert, bl_vert, br_vert, f_d_texture); |
235 | - // Draw the roads |
236 | - draw_roads_opengl(subwin, roads, f_vert, r_vert, bl_vert, br_vert); |
237 | - } |
238 | -#endif |
239 | + |
240 | } |
241 | |
242 | /* |
243 | @@ -1376,35 +1341,3 @@ |
244 | |
245 | m_surface->blit(Point(rc.x, rc.y), picture, rc2); |
246 | } |
247 | - |
248 | -void GameView::rendermap_init() |
249 | -{ |
250 | -#ifdef USE_OPENGL |
251 | - if (g_opengl) { |
252 | - glMatrixMode(GL_TEXTURE); |
253 | - glLoadIdentity(); |
254 | - glScalef |
255 | - (1.0f / static_cast<GLfloat>(TEXTURE_WIDTH), |
256 | - 1.0f / static_cast<GLfloat>(TEXTURE_HEIGHT), 1); |
257 | - glDisable(GL_BLEND); |
258 | - |
259 | - // Use scissor test to clip the window. This takes coordinates in screen |
260 | - // coordinates (y goes from bottom to top) |
261 | - glScissor |
262 | - (m_rect.x, g_gr->get_yres() - m_rect.y - m_rect.h, |
263 | - m_rect.w, m_rect.h); |
264 | - glEnable(GL_SCISSOR_TEST); |
265 | - } |
266 | -#endif |
267 | -} |
268 | - |
269 | -void GameView::rendermap_deint() |
270 | -{ |
271 | -#ifdef USE_OPENGL |
272 | - if (g_opengl) { |
273 | - glDisable(GL_SCISSOR_TEST); |
274 | - glMatrixMode(GL_TEXTURE); |
275 | - glLoadIdentity(); |
276 | - } |
277 | -#endif |
278 | -} |
279 | |
280 | === modified file 'src/graphic/render/gameview.h' |
281 | --- src/graphic/render/gameview.h 2012-01-09 21:10:43 +0000 |
282 | +++ src/graphic/render/gameview.h 2012-02-20 16:00:42 +0000 |
283 | @@ -1,5 +1,5 @@ |
284 | /* |
285 | - * Copyright (C) 2010-2011 by the Widelands Development Team |
286 | + * Copyright (C) 2010-2012 by the Widelands Development Team |
287 | * |
288 | * This program is free software; you can redistribute it and/or |
289 | * modify it under the terms of the GNU General Public License |
290 | @@ -46,7 +46,7 @@ |
291 | public: |
292 | GameView(RenderTarget & rt): |
293 | RenderTarget(rt) {} |
294 | - ~GameView() {} |
295 | + virtual ~GameView() {} |
296 | |
297 | /** |
298 | * Renders the map from a player's point of view into the current drawing |
299 | @@ -80,12 +80,12 @@ |
300 | Point viewpoint, |
301 | uint32_t flags); |
302 | |
303 | -private: |
304 | +protected: |
305 | /** |
306 | * Helper function to draw two terrain triangles. This is called from the |
307 | * rendermap() functions. |
308 | */ |
309 | - void draw_field |
310 | + virtual void draw_field |
311 | (Rect & subwin, |
312 | Vertex const & f_vert, |
313 | Vertex const & r_vert, |
314 | @@ -109,12 +109,12 @@ |
315 | /** |
316 | * This is called before the view of the game is rendered. |
317 | */ |
318 | - void rendermap_init(); |
319 | + virtual void rendermap_init() {} |
320 | |
321 | /** |
322 | * This is called after the view of the game is rendered. |
323 | */ |
324 | - void rendermap_deint(); |
325 | + virtual void rendermap_deint() {} |
326 | }; |
327 | |
328 | #endif //WIDELANDS_GAMEVIEW_H |
329 | |
330 | === added file 'src/graphic/render/gameview_opengl.cc' |
331 | --- src/graphic/render/gameview_opengl.cc 1970-01-01 00:00:00 +0000 |
332 | +++ src/graphic/render/gameview_opengl.cc 2012-02-20 16:00:42 +0000 |
333 | @@ -0,0 +1,101 @@ |
334 | +/* |
335 | + * Copyright (C) 2011-2012 by the Widelands Development Team |
336 | + * |
337 | + * This program is free software; you can redistribute it and/or |
338 | + * modify it under the terms of the GNU General Public License |
339 | + * as published by the Free Software Foundation; either version 2 |
340 | + * of the License, or (at your option) any later version. |
341 | + * |
342 | + * This program is distributed in the hope that it will be useful, |
343 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
344 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
345 | + * GNU General Public License for more details. |
346 | + * |
347 | + * You should have received a copy of the GNU General Public License |
348 | + * along with this program; if not, write to the Free Software |
349 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
350 | + * |
351 | + */ |
352 | + |
353 | + |
354 | +#include "gameview_opengl.h" |
355 | + |
356 | +#include "constants.h" |
357 | +#include "economy/road.h" |
358 | +#include "graphic/graphic.h" |
359 | +#include "graphic/texture.h" |
360 | + |
361 | +#include "terrain_opengl.h" |
362 | + |
363 | +using namespace Widelands; |
364 | + |
365 | +/** |
366 | + * Draw ground textures and roads for the given parallelogram (two triangles) |
367 | + * into the bitmap. |
368 | + * |
369 | + * Vertices: |
370 | + * - f_vert vertex of the field |
371 | + * - r_vert vertex right of the field |
372 | + * - bl_vert vertex bottom left of the field |
373 | + * - br_vert vertex bottom right of the field |
374 | + * |
375 | + * Textures: |
376 | + * - f_r_texture Terrain of the triangle right of the field |
377 | + * - f_d_texture Terrain of the triangle under of the field |
378 | + * - tr_d_texture Terrain of the triangle top of the right triangle ?? |
379 | + * - l_r_texture Terrain of the triangle left of the down triangle ?? |
380 | + * |
381 | + * (tr_d) |
382 | + * |
383 | + * (f) *------* (r) |
384 | + * / \ r / |
385 | + * (l_r) / \ / |
386 | + * / d \/ |
387 | + * (bl) *------* (br) |
388 | + */ |
389 | +void GameViewOpenGL::draw_field |
390 | + (Rect & subwin, |
391 | + Vertex const & f_vert, |
392 | + Vertex const & r_vert, |
393 | + Vertex const & bl_vert, |
394 | + Vertex const & br_vert, |
395 | + uint8_t roads, |
396 | + Texture const & tr_d_texture, |
397 | + Texture const & l_r_texture, |
398 | + Texture const & f_d_texture, |
399 | + Texture const & f_r_texture) |
400 | +{ |
401 | + // Draw triangle right (bottom) of the field |
402 | + draw_field_opengl |
403 | + (subwin, f_vert, br_vert, r_vert, f_r_texture, f_d_texture, tr_d_texture); |
404 | + // Draw triangle bottom of the field |
405 | + draw_field_opengl |
406 | + (subwin, f_vert, bl_vert, br_vert, f_d_texture, l_r_texture, f_d_texture); |
407 | + |
408 | + // Draw the roads |
409 | + draw_roads_opengl(subwin, roads, f_vert, r_vert, bl_vert, br_vert); |
410 | +} |
411 | + |
412 | +void GameViewOpenGL::rendermap_init() |
413 | +{ |
414 | + glMatrixMode(GL_TEXTURE); |
415 | + glLoadIdentity(); |
416 | + glScalef |
417 | + (1.0f / static_cast<GLfloat>(TEXTURE_WIDTH), |
418 | + 1.0f / static_cast<GLfloat>(TEXTURE_HEIGHT), 1); |
419 | + glDisable(GL_BLEND); |
420 | + |
421 | + // Use scissor test to clip the window. This takes coordinates in screen |
422 | + // coordinates (y goes from bottom to top) |
423 | + glScissor |
424 | + (m_rect.x, g_gr->get_yres() - m_rect.y - m_rect.h, |
425 | + m_rect.w, m_rect.h); |
426 | + glEnable(GL_SCISSOR_TEST); |
427 | +} |
428 | + |
429 | +void GameViewOpenGL::rendermap_deint() |
430 | +{ |
431 | + glDisable(GL_SCISSOR_TEST); |
432 | + glMatrixMode(GL_TEXTURE); |
433 | + glLoadIdentity(); |
434 | +} |
435 | |
436 | === added file 'src/graphic/render/gameview_opengl.h' |
437 | --- src/graphic/render/gameview_opengl.h 1970-01-01 00:00:00 +0000 |
438 | +++ src/graphic/render/gameview_opengl.h 2012-02-20 16:00:42 +0000 |
439 | @@ -0,0 +1,54 @@ |
440 | +/* |
441 | + * Copyright (C) 2011 by the Widelands Development Team |
442 | + * |
443 | + * This program is free software; you can redistribute it and/or |
444 | + * modify it under the terms of the GNU General Public License |
445 | + * as published by the Free Software Foundation; either version 2 |
446 | + * of the License, or (at your option) any later version. |
447 | + * |
448 | + * This program is distributed in the hope that it will be useful, |
449 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
450 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
451 | + * GNU General Public License for more details. |
452 | + * |
453 | + * You should have received a copy of the GNU General Public License |
454 | + * along with this program; if not, write to the Free Software |
455 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
456 | + * |
457 | + */ |
458 | + |
459 | +#ifndef GAMEVIEW_OPENGL_H_ |
460 | +#define GAMEVIEW_OPENGL_H_ |
461 | + |
462 | +#include "gameview.h" |
463 | + |
464 | +class GameViewOpenGL : public GameView |
465 | +{ |
466 | +public: |
467 | + GameViewOpenGL(RenderTarget & rt): |
468 | + GameView(rt) {} |
469 | + ~GameViewOpenGL() {} |
470 | + |
471 | +protected: |
472 | + /** |
473 | + * Helper function to draw two terrain triangles. This is called from the |
474 | + * rendermap() functions. |
475 | + */ |
476 | + void draw_field |
477 | + (Rect & subwin, |
478 | + Vertex const & f_vert, |
479 | + Vertex const & r_vert, |
480 | + Vertex const & bl_vert, |
481 | + Vertex const & br_vert, |
482 | + uint8_t roads, |
483 | + Texture const & tr_d_texture, |
484 | + Texture const & l_r_texture, |
485 | + Texture const & f_d_texture, |
486 | + Texture const & f_r_texture); |
487 | + |
488 | + void rendermap_init(); |
489 | + void rendermap_deint(); |
490 | +}; |
491 | + |
492 | + |
493 | +#endif /* GAMEVIEW_OPENGL_H_ */ |
494 | |
495 | === added file 'src/graphic/render/gameview_sdl.cc' |
496 | --- src/graphic/render/gameview_sdl.cc 1970-01-01 00:00:00 +0000 |
497 | +++ src/graphic/render/gameview_sdl.cc 2012-02-20 16:00:42 +0000 |
498 | @@ -0,0 +1,105 @@ |
499 | +/* |
500 | + * Copyright (C) 2011-2012 by the Widelands Development Team |
501 | + * |
502 | + * This program is free software; you can redistribute it and/or |
503 | + * modify it under the terms of the GNU General Public License |
504 | + * as published by the Free Software Foundation; either version 2 |
505 | + * of the License, or (at your option) any later version. |
506 | + * |
507 | + * This program is distributed in the hope that it will be useful, |
508 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
509 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
510 | + * GNU General Public License for more details. |
511 | + * |
512 | + * You should have received a copy of the GNU General Public License |
513 | + * along with this program; if not, write to the Free Software |
514 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
515 | + * |
516 | + */ |
517 | + |
518 | +#include "gameview_sdl.h" |
519 | + |
520 | +#include "upcast.h" |
521 | + |
522 | +#include "economy/road.h" |
523 | +#include "economy/flag.h" |
524 | + |
525 | +#include "wui/minimap.h" |
526 | +#include "wui/mapviewpixelconstants.h" |
527 | + |
528 | +#include "logic/field.h" |
529 | +#include "logic/map.h" |
530 | +#include "logic/player.h" |
531 | + |
532 | +#include "graphic/graphic.h" |
533 | +#include "graphic/rendertarget.h" |
534 | +#include "graphic/surface.h" |
535 | +#include "surface_sdl.h" |
536 | +#include "graphic/texture.h" |
537 | + |
538 | +#include "wui/overlay_manager.h" |
539 | + |
540 | +#include "terrain_sdl.h" |
541 | + |
542 | + |
543 | +/** |
544 | + * Draw ground textures and roads for the given parallelogram (two triangles) |
545 | + * into the bitmap. |
546 | + * |
547 | + * Vertices: |
548 | + * - f_vert vertex of the field |
549 | + * - r_vert vertex right of the field |
550 | + * - bl_vert vertex bottom left of the field |
551 | + * - br_vert vertex bottom right of the field |
552 | + * |
553 | + * Textures: |
554 | + * - f_r_texture Terrain of the triangle right of the field |
555 | + * - f_d_texture Terrain of the triangle under of the field |
556 | + * - tr_d_texture Terrain of the triangle top of the right triangle ?? |
557 | + * - l_r_texture Terrain of the triangle left of the down triangle ?? |
558 | + * |
559 | + * (tr_d) |
560 | + * |
561 | + * (f) *------* (r) |
562 | + * / \ r / |
563 | + * (l_r) / \ / |
564 | + * / d \/ |
565 | + * (bl) *------* (br) |
566 | + */ |
567 | +void GameViewSDL::draw_field |
568 | + (Rect & subwin, |
569 | + Vertex const & f_vert, |
570 | + Vertex const & r_vert, |
571 | + Vertex const & bl_vert, |
572 | + Vertex const & br_vert, |
573 | + uint8_t roads, |
574 | + Texture const & tr_d_texture, |
575 | + Texture const & l_r_texture, |
576 | + Texture const & f_d_texture, |
577 | + Texture const & f_r_texture) |
578 | +{ |
579 | + upcast(SurfaceSDL, sdlsurf, m_surface.get()); |
580 | + if (sdlsurf) |
581 | + { |
582 | + sdlsurf->set_subwin(subwin); |
583 | + switch (sdlsurf->format().BytesPerPixel) { |
584 | + case 2: |
585 | + draw_field_int<Uint16> |
586 | + (*sdlsurf, |
587 | + f_vert, r_vert, bl_vert, br_vert, |
588 | + roads, |
589 | + tr_d_texture, l_r_texture, f_d_texture, f_r_texture); |
590 | + break; |
591 | + case 4: |
592 | + draw_field_int<Uint32> |
593 | + (*sdlsurf, |
594 | + f_vert, r_vert, bl_vert, br_vert, |
595 | + roads, |
596 | + tr_d_texture, l_r_texture, f_d_texture, f_r_texture); |
597 | + break; |
598 | + default: |
599 | + assert(false); |
600 | + } |
601 | + sdlsurf->unset_subwin(); |
602 | + } |
603 | +} |
604 | |
605 | === added file 'src/graphic/render/gameview_sdl.h' |
606 | --- src/graphic/render/gameview_sdl.h 1970-01-01 00:00:00 +0000 |
607 | +++ src/graphic/render/gameview_sdl.h 2012-02-20 16:00:42 +0000 |
608 | @@ -0,0 +1,50 @@ |
609 | +/* |
610 | + * Copyright (C) 2011-2012 by the Widelands Development Team |
611 | + * |
612 | + * This program is free software; you can redistribute it and/or |
613 | + * modify it under the terms of the GNU General Public License |
614 | + * as published by the Free Software Foundation; either version 2 |
615 | + * of the License, or (at your option) any later version. |
616 | + * |
617 | + * This program is distributed in the hope that it will be useful, |
618 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
619 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
620 | + * GNU General Public License for more details. |
621 | + * |
622 | + * You should have received a copy of the GNU General Public License |
623 | + * along with this program; if not, write to the Free Software |
624 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
625 | + * |
626 | + */ |
627 | + |
628 | +#ifndef GAMEVIEW_SDL_H_ |
629 | +#define GAMEVIEW_SDL_H_ |
630 | + |
631 | +#include "gameview.h" |
632 | + |
633 | +class GameViewSDL : public GameView |
634 | +{ |
635 | +public: |
636 | + GameViewSDL(RenderTarget & rt): |
637 | + GameView(rt) {} |
638 | + ~GameViewSDL() {} |
639 | + |
640 | +protected: |
641 | + /** |
642 | + * Helper function to draw two terrain triangles. This is called from the |
643 | + * rendermap() functions. |
644 | + */ |
645 | + void draw_field |
646 | + (Rect & subwin, |
647 | + Vertex const & f_vert, |
648 | + Vertex const & r_vert, |
649 | + Vertex const & bl_vert, |
650 | + Vertex const & br_vert, |
651 | + uint8_t roads, |
652 | + Texture const & tr_d_texture, |
653 | + Texture const & l_r_texture, |
654 | + Texture const & f_d_texture, |
655 | + Texture const & f_r_texture); |
656 | +}; |
657 | + |
658 | +#endif /* GAMEVIEW_SDL_H_ */ |
659 | |
660 | === modified file 'src/graphic/render/terrain_opengl.h' |
661 | --- src/graphic/render/terrain_opengl.h 2011-11-30 21:38:37 +0000 |
662 | +++ src/graphic/render/terrain_opengl.h 2012-02-20 16:00:42 +0000 |
663 | @@ -1,5 +1,5 @@ |
664 | /* |
665 | - * Copyright (C) 2010 by the Widelands Development Team |
666 | + * Copyright (C) 2010-2012 by the Widelands Development Team |
667 | * |
668 | * This program is free software; you can redistribute it and/or |
669 | * modify it under the terms of the GNU General Public License |
670 | @@ -18,6 +18,8 @@ |
671 | */ |
672 | |
673 | #ifdef USE_OPENGL |
674 | +#ifndef TERRAIN_OPENGL_H |
675 | +#define TERRAIN_OPENGL_H |
676 | |
677 | #include "gl_picture_texture.h" |
678 | #include "vertex.h" |
679 | @@ -28,13 +30,13 @@ |
680 | Vertex const & p1, |
681 | Vertex const & p2, |
682 | Vertex const & p3, |
683 | - Texture const & texture) |
684 | + Texture const & texture, |
685 | + Texture const & left_texture, |
686 | + Texture const & top_texture) |
687 | { |
688 | if (p1.b <= -128 and p2.b <= -128 and p3.b <= -128) |
689 | return; |
690 | |
691 | - glBindTexture(GL_TEXTURE_2D, texture.getTexture()); |
692 | - |
693 | Vertex t1(p1), t2(p2), t3(p3); |
694 | |
695 | t1.x = p1.x + subwin.x; |
696 | @@ -49,39 +51,147 @@ |
697 | if (t1.y < subwin.y and t2.y < subwin.y and t3.y < subwin.y) |
698 | return; |
699 | |
700 | - { |
701 | - int const subxr = subwin.x + subwin.w; |
702 | - if (t1.x > subxr and t2.x > subxr and t3.x > subxr) |
703 | - return; |
704 | - } |
705 | - { |
706 | - int const subyd = subwin.y + subwin.h; |
707 | - if (t1.y > subyd and t2.y > subyd and t3.y > subyd) |
708 | - return; |
709 | - } |
710 | + int const subxr = subwin.x + subwin.w; |
711 | + if (t1.x > subxr and t2.x > subxr and t3.x > subxr) |
712 | + return; |
713 | + |
714 | + int const subyd = subwin.y + subwin.h; |
715 | + if (t1.y > subyd and t2.y > subyd and t3.y > subyd) |
716 | + return; |
717 | + |
718 | + glEnable(GL_BLEND); |
719 | + |
720 | + // load current texture |
721 | + glActiveTexture(GL_TEXTURE0); |
722 | + glEnable(GL_TEXTURE_2D); |
723 | + glBindTexture(GL_TEXTURE_2D, texture.getTexture()); |
724 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
725 | + |
726 | + if ((&top_texture != &texture) and not (p1.b == -128 and p3.b == -128)) { |
727 | + // load top texture |
728 | + glActiveTexture(GL_TEXTURE1); |
729 | + glEnable(GL_TEXTURE_2D); |
730 | + glBindTexture(GL_TEXTURE_2D, top_texture.getTexture()); |
731 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
732 | + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
733 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS); |
734 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
735 | + |
736 | + GLuint edge = dynamic_cast<GLPictureTexture const &> |
737 | + (*g_gr->get_edge_texture()).get_gl_texture(); |
738 | + |
739 | + // combine current and top texture |
740 | + glActiveTexture(GL_TEXTURE2); |
741 | + glEnable(GL_TEXTURE_2D); |
742 | + glBindTexture(GL_TEXTURE_2D, edge); |
743 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
744 | + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); |
745 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS); |
746 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE1); |
747 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE); |
748 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
749 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); |
750 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR); |
751 | + } |
752 | + |
753 | + if ((&left_texture != &texture) and not (p1.b == -128 and p2.b == -128)) { |
754 | + // load left texture |
755 | + glActiveTexture(GL_TEXTURE3); |
756 | + glEnable(GL_TEXTURE_2D); |
757 | + glBindTexture(GL_TEXTURE_2D, left_texture.getTexture()); |
758 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
759 | + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
760 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS); |
761 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
762 | + |
763 | + GLuint edge = dynamic_cast<GLPictureTexture const &> |
764 | + (*g_gr->get_edge_texture()).get_gl_texture(); |
765 | + |
766 | + // combine current and left texture |
767 | + glActiveTexture(GL_TEXTURE4); |
768 | + glEnable(GL_TEXTURE_2D); |
769 | + glBindTexture(GL_TEXTURE_2D, edge); |
770 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
771 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
772 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
773 | + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); |
774 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS); |
775 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE3); |
776 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE); |
777 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
778 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); |
779 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR); |
780 | + } |
781 | + |
782 | + // Fade effect for fog of war |
783 | + glActiveTexture(GL_TEXTURE5); |
784 | + glEnable(GL_TEXTURE_2D); |
785 | + // texture does not matter but one has to be bound |
786 | + glBindTexture(GL_TEXTURE_2D, texture.getTexture()); |
787 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
788 | + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); |
789 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS); |
790 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
791 | + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); |
792 | + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); |
793 | |
794 | glBegin(GL_TRIANGLES); { |
795 | { |
796 | GLfloat const brightness = (150.0 + p1.b) / 150.0; |
797 | glColor3f(brightness, brightness, brightness); |
798 | } |
799 | - glTexCoord2i(t1.tx, t1.ty); |
800 | + glMultiTexCoord2i(GL_TEXTURE0, t1.tx, t1.ty); |
801 | + glMultiTexCoord2f(GL_TEXTURE1, t1.tx / TEXTURE_WIDTH, t1.ty / TEXTURE_WIDTH); |
802 | + glMultiTexCoord2f(GL_TEXTURE2, 0, 0); |
803 | + glMultiTexCoord2f(GL_TEXTURE3, t1.tx / TEXTURE_WIDTH, t1.ty / TEXTURE_WIDTH); |
804 | + glMultiTexCoord2f(GL_TEXTURE4, 1, 0); |
805 | + glMultiTexCoord2f(GL_TEXTURE5, t1.tx / TEXTURE_WIDTH, t1.ty / TEXTURE_WIDTH); |
806 | glVertex2f(t1.x, t1.y); |
807 | |
808 | { |
809 | GLfloat const brightness = (150.0 + p2.b) / 150.0; |
810 | glColor3f(brightness, brightness, brightness); |
811 | } |
812 | - glTexCoord2i(t2.tx, t2.ty); |
813 | + glMultiTexCoord2i(GL_TEXTURE0, t2.tx, t2.ty); |
814 | + glMultiTexCoord2f(GL_TEXTURE1, t2.tx / TEXTURE_WIDTH, t2.ty / TEXTURE_WIDTH); |
815 | + glMultiTexCoord2f(GL_TEXTURE2, 0.5, 1); |
816 | + glMultiTexCoord2f(GL_TEXTURE3, t2.tx / TEXTURE_WIDTH, t2.ty / TEXTURE_WIDTH); |
817 | + glMultiTexCoord2f(GL_TEXTURE4, 0, 0); |
818 | + glMultiTexCoord2f(GL_TEXTURE5, t2.tx / TEXTURE_WIDTH, t2.ty / TEXTURE_WIDTH); |
819 | glVertex2f(t2.x, t2.y); |
820 | |
821 | { |
822 | GLfloat const brightness = (150.0 + p3.b) / 150.0; |
823 | glColor3f(brightness, brightness, brightness); |
824 | } |
825 | - glTexCoord2i(t3.tx, t3.ty); |
826 | + glMultiTexCoord2i(GL_TEXTURE0, t3.tx, t3.ty); |
827 | + glMultiTexCoord2f(GL_TEXTURE1, t3.tx / TEXTURE_WIDTH, t3.ty / TEXTURE_WIDTH); |
828 | + glMultiTexCoord2f(GL_TEXTURE2, 1, 0); |
829 | + glMultiTexCoord2f(GL_TEXTURE3, t3.tx / TEXTURE_WIDTH, t3.ty / TEXTURE_WIDTH); |
830 | + glMultiTexCoord2f(GL_TEXTURE4, 0.5, 1); |
831 | + glMultiTexCoord2f(GL_TEXTURE5, t3.tx / TEXTURE_WIDTH, t3.ty / TEXTURE_WIDTH); |
832 | glVertex2f(t3.x, t3.y); |
833 | } glEnd(); |
834 | + |
835 | + // Cleanup OpenGL |
836 | + glActiveTexture(GL_TEXTURE5); |
837 | + glDisable(GL_TEXTURE_2D); |
838 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
839 | + glActiveTexture(GL_TEXTURE4); |
840 | + glDisable(GL_TEXTURE_2D); |
841 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
842 | + glActiveTexture(GL_TEXTURE3); |
843 | + glDisable(GL_TEXTURE_2D); |
844 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
845 | + glActiveTexture(GL_TEXTURE2); |
846 | + glDisable(GL_TEXTURE_2D); |
847 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
848 | + glActiveTexture(GL_TEXTURE1); |
849 | + glDisable(GL_TEXTURE_2D); |
850 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
851 | + glActiveTexture(GL_TEXTURE0); |
852 | + glEnable(GL_TEXTURE_2D); |
853 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
854 | } |
855 | |
856 | #define horiz_road_opengl(tex, start, end) \ |
857 | @@ -93,7 +203,7 @@ |
858 | glVertex2f(subwin.x + end.x, subwin.y + end.y - 2); \ |
859 | glTexCoord2i(TEXTURE_WIDTH, 4); \ |
860 | glVertex2f(subwin.x + end.x, subwin.y + end.y + 2); \ |
861 | - glTexCoord2i(TEXTURE_WIDTH, 4); \ |
862 | + glTexCoord2i(0, 4); \ |
863 | glVertex2f(subwin.x + start.x, subwin.y + start.y + 2); \ |
864 | } glEnd(); \ |
865 | |
866 | @@ -106,7 +216,7 @@ |
867 | glVertex2f(subwin.x + start.x + 3, subwin.y + start.y); \ |
868 | glTexCoord2i(TEXTURE_WIDTH, TEXTURE_HEIGHT); \ |
869 | glVertex2f(subwin.x + end.x + 3, subwin.y + end.y); \ |
870 | - glTexCoord2i(TEXTURE_WIDTH - 6, TEXTURE_HEIGHT); \ |
871 | + glTexCoord2i(TEXTURE_WIDTH - 6, TEXTURE_HEIGHT); \ |
872 | glVertex2f(subwin.x + end.x - 3, subwin.y + end.y); \ |
873 | } glEnd(); \ |
874 | |
875 | @@ -174,3 +284,4 @@ |
876 | } |
877 | |
878 | #endif |
879 | +#endif |
880 | |
881 | === modified file 'src/graphic/texture.cc' |
882 | --- src/graphic/texture.cc 2011-11-30 21:38:37 +0000 |
883 | +++ src/graphic/texture.cc 2012-02-20 16:00:42 +0000 |
884 | @@ -1,5 +1,5 @@ |
885 | /* |
886 | - * Copyright (C) 2002-2004, 2006, 2010 by the Widelands Development Team |
887 | + * Copyright (C) 2002-2004, 2006, 2010, 2012 by the Widelands Development Team |
888 | * |
889 | * This program is free software; you can redistribute it and/or |
890 | * modify it under the terms of the GNU General Public License |
891 | @@ -106,16 +106,38 @@ |
892 | boost::shared_ptr<GLPictureTexture> surface(new GLPictureTexture(surf)); |
893 | m_glFrames.push_back(surface); |
894 | |
895 | - surface->lock(IPixelAccess::Lock_Normal); |
896 | - m_mmap_color = surface->get_pixel(0, 0); |
897 | - surface->unlock(IPixelAccess::Unlock_NoChange); |
898 | + // calculate shades on the first frame |
899 | + if (!m_nrframes) { |
900 | + surface->lock(IPixelAccess::Lock_Normal); |
901 | + uint32_t mmap_color_base = surface->get_pixel(0, 0); |
902 | + surface->unlock(IPixelAccess::Unlock_NoChange); |
903 | + |
904 | + int32_t i, shade, r, g, b, a; |
905 | + for (i = -128; i < 128; i++) { |
906 | + shade = 128 + i; |
907 | + |
908 | + a = (mmap_color_base & 0xff000000) >> 24; |
909 | + b = (mmap_color_base & 0x00ff0000) >> 16; |
910 | + g = (mmap_color_base & 0x0000ff00) >> 8; |
911 | + r = (mmap_color_base & 0x000000ff); |
912 | + |
913 | + b = (b * shade) >> 7; |
914 | + g = (g * shade) >> 7; |
915 | + r = (r * shade) >> 7; |
916 | + |
917 | + if (b > 255) b = 255; |
918 | + if (g > 255) g = 255; |
919 | + if (r > 255) r = 255; |
920 | + |
921 | + m_mmap_color[shade] = (a << 24) | (b << 16) | (g << 8) | r; |
922 | + } |
923 | + } |
924 | |
925 | ++m_nrframes; |
926 | continue; |
927 | } |
928 | #endif |
929 | |
930 | - |
931 | // Determine color map if it's the first frame |
932 | if (!m_nrframes) { |
933 | if (surf->format->BitsPerPixel == 8) |
934 | @@ -187,8 +209,11 @@ |
935 | * Return the basic terrain colour to be used in the minimap. |
936 | */ |
937 | Uint32 Texture::get_minimap_color(const char shade) { |
938 | + assert(shade >= -128); |
939 | + assert(shade <= 127); |
940 | + |
941 | if (not m_pixels) |
942 | - return m_mmap_color; |
943 | + return m_mmap_color[128 + shade]; |
944 | |
945 | uint8_t clr = m_pixels[0]; // just use the top-left pixel |
946 | uint32_t table = static_cast<uint8_t>(shade); |
947 | |
948 | === modified file 'src/graphic/texture.h' |
949 | --- src/graphic/texture.h 2012-01-09 21:10:43 +0000 |
950 | +++ src/graphic/texture.h 2012-02-20 16:00:42 +0000 |
951 | @@ -1,5 +1,5 @@ |
952 | /* |
953 | - * Copyright (C) 2002-2004, 2006, 2008-2010 by the Widelands Development Team |
954 | + * Copyright (C) 2002-2004, 2006, 2008-2010, 2012 by the Widelands Development Team |
955 | * |
956 | * This program is free software; you can redistribute it and/or |
957 | * modify it under the terms of the GNU General Public License |
958 | @@ -71,7 +71,7 @@ |
959 | private: |
960 | Colormap * m_colormap; |
961 | uint8_t * m_pixels; |
962 | - uint32_t m_mmap_color; |
963 | + uint32_t m_mmap_color[256]; |
964 | uint8_t * m_curframe; |
965 | int32_t m_frame_num; |
966 | char * m_texture_picture; |
967 | |
968 | === modified file 'src/ui_fsmenu/options.cc' |
969 | --- src/ui_fsmenu/options.cc 2012-01-21 13:09:23 +0000 |
970 | +++ src/ui_fsmenu/options.cc 2012-02-20 16:00:42 +0000 |
971 | @@ -1,5 +1,5 @@ |
972 | /* |
973 | - * Copyright (C) 2002-2004, 2006-2010 by Widelands Development Team |
974 | + * Copyright (C) 2002-2004, 2006-2010, 2012 by Widelands Development Team |
975 | * |
976 | * This program is free software; you can redistribute it and/or |
977 | * modify it under the terms of the GNU General Public License |
978 | @@ -468,7 +468,7 @@ |
979 | m_label_opengl |
980 | (this, |
981 | get_w() * 1313 / 10000, get_h() * 8330 / 10000, |
982 | - _("OpenGL rendering *Highly experimental!*"), UI::Align_VCenter), |
983 | + _("OpenGL rendering"), UI::Align_VCenter), |
984 | m_transparent_chat (this, Point(get_w() * 19 / 200, get_h() * 8645 / 10000)), |
985 | m_label_transparent_chat |
986 | (this, |
987 | @@ -658,7 +658,7 @@ |
988 | opt.remove_syncstreams = m_opt_section.get_bool |
989 | ("remove_syncstreams", true); |
990 | opt.opengl = m_opt_section.get_bool |
991 | - ("opengl", false); |
992 | + ("opengl", true); |
993 | opt.transparent_chat = m_opt_section.get_bool |
994 | ("transparent_chat", true); |
995 | return opt; |
996 | |
997 | === modified file 'src/wlapplication.cc' |
998 | --- src/wlapplication.cc 2012-02-07 12:14:30 +0000 |
999 | +++ src/wlapplication.cc 2012-02-20 16:00:42 +0000 |
1000 | @@ -264,7 +264,7 @@ |
1001 | m_should_die (false), |
1002 | m_gfx_w(0), m_gfx_h(0), |
1003 | m_gfx_fullscreen (false), |
1004 | -m_gfx_opengl (false), |
1005 | +m_gfx_opengl (true), |
1006 | m_default_datadirs (true), |
1007 | m_homedir(FileSystem::GetHomedir() + "/.widelands"), |
1008 | m_redirected_stdio(false) |
1009 | @@ -512,6 +512,10 @@ |
1010 | g_sound_handler.change_music(); |
1011 | |
1012 | break; |
1013 | + case SDL_VIDEOEXPOSE: |
1014 | + //log ("SDL Video Window expose event: %i\n", ev.expose.type); |
1015 | + g_gr->update_fullscreen(); |
1016 | + break; |
1017 | } |
1018 | } |
1019 | } |
1020 | @@ -807,7 +811,7 @@ |
1021 | m_gfx_fullscreen = s.get_bool("fullscreen", false); |
1022 | |
1023 | #if USE_OPENGL |
1024 | - m_gfx_opengl = s.get_bool("opengl", false); |
1025 | + m_gfx_opengl = s.get_bool("opengl", true); |
1026 | #endif |
1027 | |
1028 | // KLUDGE! |
1029 | @@ -1352,8 +1356,7 @@ |
1030 | << |
1031 | _ |
1032 | (" --opengl=[0|1]\n" |
1033 | - " Enables opengl rendering\n" |
1034 | - " *EXPERIMENTAL*\n") |
1035 | + " Enables OpenGL rendering\n") |
1036 | #endif |
1037 | << |
1038 | _ |
1039 | |
1040 | === modified file 'src/wui/mapview.cc' |
1041 | --- src/wui/mapview.cc 2011-11-30 21:38:37 +0000 |
1042 | +++ src/wui/mapview.cc 2012-02-20 16:00:42 +0000 |
1043 | @@ -31,6 +31,8 @@ |
1044 | #include "graphic/graphic.h" |
1045 | #include "graphic/rendertarget.h" |
1046 | #include "graphic/render/gameview.h" |
1047 | +#include "graphic/render/gameview_opengl.h" |
1048 | +#include "graphic/render/gameview_sdl.h" |
1049 | |
1050 | #include "upcast.h" |
1051 | |
1052 | @@ -93,12 +95,17 @@ |
1053 | |
1054 | egbase.map().overlay_manager().load_graphics(); |
1055 | |
1056 | - GameView gameview(dst); |
1057 | + GameView * gameview; |
1058 | + if (g_opengl) { |
1059 | + gameview = new GameViewOpenGL(dst); |
1060 | + } else { |
1061 | + gameview = new GameViewSDL(dst); |
1062 | + } |
1063 | |
1064 | if (upcast(Interactive_Player const, interactive_player, &intbase())) |
1065 | - gameview.rendermap(egbase, interactive_player->player(), m_viewpoint); |
1066 | + gameview->rendermap(egbase, interactive_player->player(), m_viewpoint); |
1067 | else |
1068 | - gameview.rendermap(egbase, m_viewpoint); |
1069 | + gameview->rendermap(egbase, m_viewpoint); |
1070 | |
1071 | m_complete_redraw_needed = false; |
1072 | if (char const * const text = tooltip()) |
1073 | |
1074 | === added file 'worlds/blackland/pics/edge.png' |
1075 | Binary files worlds/blackland/pics/edge.png 1970-01-01 00:00:00 +0000 and worlds/blackland/pics/edge.png 2012-02-20 16:00:42 +0000 differ |
1076 | === modified file 'worlds/blackland/pics/roadt_busy.png' |
1077 | Binary files worlds/blackland/pics/roadt_busy.png 2011-08-21 14:24:10 +0000 and worlds/blackland/pics/roadt_busy.png 2012-02-20 16:00:42 +0000 differ |
1078 | === modified file 'worlds/blackland/pics/roadt_normal.png' |
1079 | Binary files worlds/blackland/pics/roadt_normal.png 2011-08-21 14:24:10 +0000 and worlds/blackland/pics/roadt_normal.png 2012-02-20 16:00:42 +0000 differ |
1080 | === added file 'worlds/desert/pics/edge.png' |
1081 | Binary files worlds/desert/pics/edge.png 1970-01-01 00:00:00 +0000 and worlds/desert/pics/edge.png 2012-02-20 16:00:42 +0000 differ |
1082 | === modified file 'worlds/desert/pics/roadt_busy.png' |
1083 | Binary files worlds/desert/pics/roadt_busy.png 2011-08-21 14:24:10 +0000 and worlds/desert/pics/roadt_busy.png 2012-02-20 16:00:42 +0000 differ |
1084 | === modified file 'worlds/desert/pics/roadt_normal.png' |
1085 | Binary files worlds/desert/pics/roadt_normal.png 2011-08-21 14:24:10 +0000 and worlds/desert/pics/roadt_normal.png 2012-02-20 16:00:42 +0000 differ |
1086 | === added file 'worlds/greenland/pics/edge.png' |
1087 | Binary files worlds/greenland/pics/edge.png 1970-01-01 00:00:00 +0000 and worlds/greenland/pics/edge.png 2012-02-20 16:00:42 +0000 differ |
1088 | === modified file 'worlds/greenland/pics/roadt_busy.png' |
1089 | Binary files worlds/greenland/pics/roadt_busy.png 2011-10-03 15:11:25 +0000 and worlds/greenland/pics/roadt_busy.png 2012-02-20 16:00:42 +0000 differ |
1090 | === modified file 'worlds/greenland/pics/roadt_normal.png' |
1091 | Binary files worlds/greenland/pics/roadt_normal.png 2011-10-03 15:11:25 +0000 and worlds/greenland/pics/roadt_normal.png 2012-02-20 16:00:42 +0000 differ |
1092 | === modified file 'worlds/greenland/terrainconf' |
1093 | --- worlds/greenland/terrainconf 2012-01-04 18:52:20 +0000 |
1094 | +++ worlds/greenland/terrainconf 2012-02-20 16:00:42 +0000 |
1095 | @@ -80,4 +80,3 @@ |
1096 | [bergwiese] |
1097 | name="Mountain meadow" |
1098 | is=green |
1099 | - |
1100 | |
1101 | === added file 'worlds/winterland/pics/edge.png' |
1102 | Binary files worlds/winterland/pics/edge.png 1970-01-01 00:00:00 +0000 and worlds/winterland/pics/edge.png 2012-02-20 16:00:42 +0000 differ |
1103 | === modified file 'worlds/winterland/pics/roadt_busy.png' |
1104 | Binary files worlds/winterland/pics/roadt_busy.png 2011-08-21 14:24:10 +0000 and worlds/winterland/pics/roadt_busy.png 2012-02-20 16:00:42 +0000 differ |
1105 | === modified file 'worlds/winterland/pics/roadt_normal.png' |
1106 | Binary files worlds/winterland/pics/roadt_normal.png 2011-08-21 14:24:10 +0000 and worlds/winterland/pics/roadt_normal.png 2012-02-20 16:00:42 +0000 differ |