Merge lp:~qcumber-some/widelands/make_opengl_glew_gettext_mandatory into lp:widelands

Proposed by Jens Beyer
Status: Merged
Merged at revision: 6607
Proposed branch: lp:~qcumber-some/widelands/make_opengl_glew_gettext_mandatory
Merge into: lp:widelands
Diff against target: 376 lines (+11/-68)
11 files modified
CMakeLists.txt (+8/-13)
doc/sphinx/source/compiling.rst (+3/-2)
src/graphic/graphic.cc (+0/-16)
src/graphic/render/gamerenderer_gl.cc (+0/-2)
src/graphic/render/gamerenderer_gl.h (+0/-2)
src/graphic/surface.cc (+0/-4)
src/graphic/texture.cc (+0/-4)
src/graphic/texture.h (+0/-4)
src/ui_fsmenu/options.cc (+0/-7)
src/wlapplication.cc (+0/-12)
src/wui/mapview.cc (+0/-2)
To merge this branch: bzr merge lp:~qcumber-some/widelands/make_opengl_glew_gettext_mandatory
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+156258@code.launchpad.net

Description of the change

As discussed in the bug, made opengl, glew and gettext required. I also got rid of the now superfluous definition of USE_OPENGL throughout the code.

To post a comment you must log in.
Revision history for this message
Jens Beyer (qcumber-some) wrote :

sorry I messed up the branches when pushing, now it is the correct proposal :)

Revision history for this message
SirVer (sirver) wrote :

+# OpenGL Headers are not needed directly. Instead SDL_opengl.h should be searched
I think this line is no longer correct - or is it?

Otherwise looks good to me. If someone objects of making OpenGL required - speak up now or be forever silent.

review: Needs Fixing
Revision history for this message
Jens Beyer (qcumber-some) wrote :

As far as I understand, it is some hint that find_package(OPENGL) may not be the best way to do what we need, and that we should better search for SDL_opengl.h and include its path.
This can not be done easily, it would involve another Module FindSDL_opengl.cmake to be written.

If this interpretation is correct, the line is still valid.
But I don't know who originally wrote this line and what s/he thought then.

Revision history for this message
SirVer (sirver) wrote :

I'd say remove this comment - without the OpenGL headers, the SDL_opengl.h header will not help much and if SDL is installed, it's GL header will also be available. So we really only want to check for OpenGL here and for nothing else. Agreed?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-03-17 20:34:53 +0000
3+++ CMakeLists.txt 2013-03-30 12:54:23 +0000
4@@ -304,19 +304,10 @@
5
6 # Check for opengl
7 # TODO Check for SDL_opengl.h and add to include path
8-find_package(OpenGL)
9-if (OPENGL_FOUND)
10- # OpenGL Headers are not needed directly. Instead SDL_opengl.h should be searched
11- add_definitions("-DUSE_OPENGL")
12- find_package(GLEW)
13- if (GLEW_FOUND)
14- add_definitions(${GLEW_EXTRA_DEFINITIONS})
15- else (GLEW FOUND)
16- message (STATUS "GLEW library not found, check your libraries path and installed packages!")
17- endif (GLEW_FOUND)
18-else (OPENGL_FOUND)
19- message (STATUS "OpenGL support disabled, check your libraries path and installed packages!")
20-endif (OPENGL_FOUND)
21+find_package(OpenGL REQUIRED)
22+# OpenGL Headers are not needed directly. Instead SDL_opengl.h should be searched
23+find_package(GLEW REQUIRED)
24+add_definitions(${GLEW_EXTRA_DEFINITIONS})
25
26 # ...but using MAJOR, MINOR and PATCH
27 if (DEFINED WL_VERSION_MAJOR)
28@@ -421,6 +412,10 @@
29 include_directories(${INTL_INCLUDE_DIR})
30 endif (APPLE OR WIN32 OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
31
32+# Gettext is required, but it does not provide GETTEXT_INCLUDE_DIR or
33+# GETTEXT_LIBRARY as "usual" libraries do
34+find_package(Gettext REQUIRED)
35+
36 find_package(SDL REQUIRED)
37 include_directories(${SDL_INCLUDE_DIR})
38
39
40=== modified file 'doc/sphinx/source/compiling.rst'
41--- doc/sphinx/source/compiling.rst 2012-06-15 20:29:49 +0000
42+++ doc/sphinx/source/compiling.rst 2013-03-30 12:54:23 +0000
43@@ -17,12 +17,13 @@
44 - SDL_net
45 - SDL_ttf >= 2.0.0
46 - SDL_gfx
47-- GLEW, when compiling with OpenGL support
48+- GLEW
49+- OpenGL
50 - boost >= 1.35
51 - lua >= 5.1
52 - gettext (look at FAQ if you have problems with -lintl)
53 - libpng
54-- zlib
55+- zlib (including minizip library if available for your system)
56 - libiconv (only needed under win32)
57 - libintl (only needed under win32)
58
59
60=== modified file 'src/graphic/graphic.cc'
61--- src/graphic/graphic.cc 2013-03-09 14:41:03 +0000
62+++ src/graphic/graphic.cc 2013-03-30 12:54:23 +0000
63@@ -89,23 +89,17 @@
64 SDL_WM_SetIcon(s, 0);
65 SDL_FreeSurface(s);
66
67-#ifndef USE_OPENGL
68- assert(not opengl);
69-#endif
70-
71 // Set video mode using SDL. First collect the flags
72
73 int32_t flags = 0;
74 g_opengl = false;
75 SDL_Surface * sdlsurface = 0;
76
77-#ifdef USE_OPENGL
78 if (opengl) {
79 log("Graphics: Trying opengl\n");
80 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
81 flags |= SDL_OPENGL;
82 }
83-#endif
84
85 if (fullscreen) {
86 flags |= SDL_FULLSCREEN;
87@@ -116,7 +110,6 @@
88 // Here we actually set the video mode
89 sdlsurface = SDL_SetVideoMode(w, h, bpp, flags);
90
91-#ifdef USE_OPENGL
92 // If we tried opengl and it was not successful try without opengl
93 if (!sdlsurface and opengl)
94 {
95@@ -124,7 +117,6 @@
96 flags &= ~SDL_OPENGL;
97 sdlsurface = SDL_SetVideoMode(w, h, bpp, flags);
98 }
99-#endif
100
101 if (!sdlsurface)
102 {
103@@ -148,7 +140,6 @@
104 if (0 != (sdlsurface->flags & SDL_FULLSCREEN))
105 log("Graphics: FULLSCREEN ENABLED\n");
106
107-#ifdef USE_OPENGL
108 if (0 != (sdlsurface->flags & SDL_OPENGL)) {
109 // We have successful opened an opengl screen. Print some information
110 // about opengl and set the rendering capabilities.
111@@ -213,7 +204,6 @@
112 m_caps.gl.blendequation = GLEW_VERSION_1_4 || GLEW_ARB_imaging;
113 GCC_DIAG_ON ("-Wold-style-cast")
114 }
115-#endif
116
117 /* Information about the video capabilities. */
118 const SDL_VideoInfo* info = SDL_GetVideoInfo();
119@@ -259,7 +249,6 @@
120 (("Widelands " + build_id() + '(' + build_type() + ')').c_str(),
121 "Widelands");
122
123-#if USE_OPENGL
124 if (g_opengl) {
125 glViewport(0, 0, w, h);
126
127@@ -296,7 +285,6 @@
128 screen_.reset(new GLSurfaceScreen(w, h));
129 }
130 else
131-#endif
132 {
133 screen_.reset(new SDLSurface(sdlsurface));
134 }
135@@ -321,10 +309,8 @@
136
137 flush_animations();
138
139-#if USE_OPENGL
140 if (g_opengl)
141 GLSurfaceTexture::Cleanup();
142-#endif
143 }
144
145 /**
146@@ -409,14 +395,12 @@
147 */
148 void Graphic::refresh(bool force)
149 {
150-#ifdef USE_OPENGL
151 if (g_opengl) {
152 SDL_GL_SwapBuffers();
153 m_update_fullscreen = false;
154 m_nr_update_rects = 0;
155 return;
156 }
157-#endif
158
159 if (force or m_update_fullscreen) {
160 //flip defaults to SDL_UpdateRect(m_surface, 0, 0, 0, 0);
161
162=== modified file 'src/graphic/render/gamerenderer_gl.cc'
163--- src/graphic/render/gamerenderer_gl.cc 2013-02-19 13:16:49 +0000
164+++ src/graphic/render/gamerenderer_gl.cc 2013-03-30 12:54:23 +0000
165@@ -17,7 +17,6 @@
166 *
167 */
168
169-#ifdef USE_OPENGL
170 #include "gamerenderer_gl.h"
171
172 #include "gl_surface.h"
173@@ -670,4 +669,3 @@
174 glDisableClientState(GL_COLOR_ARRAY);
175 }
176
177-#endif // USE_OPENGL
178
179=== modified file 'src/graphic/render/gamerenderer_gl.h'
180--- src/graphic/render/gamerenderer_gl.h 2013-02-09 12:22:53 +0000
181+++ src/graphic/render/gamerenderer_gl.h 2013-03-30 12:54:23 +0000
182@@ -17,7 +17,6 @@
183 *
184 */
185
186-#ifdef USE_OPENGL
187 #ifndef WIDELANDS_GAMERENDERER_GL_H
188 #define WIDELANDS_GAMERENDERER_GL_H
189
190@@ -129,4 +128,3 @@
191 };
192
193 #endif // WIDELANDS_GAMERENDERER_GL_H
194-#endif // USE_OPENGL
195
196=== modified file 'src/graphic/surface.cc'
197--- src/graphic/surface.cc 2013-02-10 13:44:17 +0000
198+++ src/graphic/surface.cc 2013-03-30 12:54:23 +0000
199@@ -28,22 +28,18 @@
200 extern bool g_opengl;
201
202 Surface* Surface::create(SDL_Surface* surf) {
203-#ifdef USE_OPENGL
204 if (g_opengl) {
205 return new GLSurfaceTexture(surf);
206 }
207-#endif
208 SDL_Surface * surface = SDL_DisplayFormatAlpha(surf);
209 SDL_FreeSurface(surf);
210 return new SDLSurface(surface);
211 }
212
213 Surface* Surface::create(uint16_t w, uint16_t h) {
214-#ifdef USE_OPENGL
215 if (g_opengl) {
216 return new GLSurfaceTexture(w, h);
217 } else
218-#endif
219 {
220 SDL_Surface* tsurf = empty_sdl_surface(w, h);
221 SDL_Surface* surf = SDL_DisplayFormatAlpha(tsurf);
222
223=== modified file 'src/graphic/texture.cc'
224--- src/graphic/texture.cc 2013-03-04 18:03:05 +0000
225+++ src/graphic/texture.cc 2013-03-30 12:54:23 +0000
226@@ -101,7 +101,6 @@
227 break;
228 }
229
230-#ifdef USE_OPENGL
231 if (g_opengl) {
232 // Note: we except the constructor to free the SDL surface
233 GLSurfaceTexture* surface = new GLSurfaceTexture(surf);
234@@ -137,7 +136,6 @@
235 ++m_nrframes;
236 continue;
237 }
238-#endif
239
240 // Determine color map if it's the first frame
241 if (!m_nrframes) {
242@@ -234,10 +232,8 @@
243 {
244 m_frame_num = (time / m_frametime) % m_nrframes;
245
246-#ifdef USE_OPENGL
247 if (g_opengl)
248 return;
249-#endif
250
251 uint8_t * const lastframe = m_curframe;
252
253
254=== modified file 'src/graphic/texture.h'
255--- src/graphic/texture.h 2013-03-03 13:14:21 +0000
256+++ src/graphic/texture.h 2013-03-30 12:54:23 +0000
257@@ -53,10 +53,8 @@
258 void animate(uint32_t time);
259 void reset_was_animated() {m_was_animated = false;}
260 bool was_animated() const throw () {return m_was_animated;}
261-#ifdef USE_OPENGL
262 uint32_t getTexture() const
263 {return m_glFrames.at(m_frame_num)->get_gl_texture();}
264-#endif
265
266 private:
267 Colormap * m_colormap;
268@@ -69,9 +67,7 @@
269 uint32_t m_frametime;
270 bool is_32bit;
271 bool m_was_animated;
272-#ifdef USE_OPENGL
273 std::vector<GLSurfaceTexture*> m_glFrames;
274-#endif
275 };
276
277 #endif
278
279=== modified file 'src/ui_fsmenu/options.cc'
280--- src/ui_fsmenu/options.cc 2013-02-21 19:02:21 +0000
281+++ src/ui_fsmenu/options.cc 2013-03-30 12:54:23 +0000
282@@ -531,9 +531,6 @@
283 m_remove_syncstreams .set_state(opt.remove_syncstreams);
284 m_label_opengl .set_textstyle(ts_small());
285 m_opengl .set_state(opt.opengl);
286-#ifndef USE_OPENGL
287- m_opengl .set_enabled(false);
288-#endif
289 m_label_transparent_chat.set_textstyle(ts_small());
290 m_transparent_chat .set_state(opt.transparent_chat);
291 m_sb_speed .set_textstyle(ts_small());
292@@ -618,11 +615,7 @@
293 os.panel_snap_distance = m_sb_dis_panel.getValue();
294 os.border_snap_distance = m_sb_dis_border.getValue();
295 os.remove_syncstreams = m_remove_syncstreams.get_state();
296-#ifdef USE_OPENGL
297 os.opengl = m_opengl.get_state();
298-#else
299- os.opengl = false;
300-#endif
301 os.transparent_chat = m_transparent_chat.get_state();
302 return os;
303 }
304
305=== modified file 'src/wlapplication.cc'
306--- src/wlapplication.cc 2013-03-08 14:17:14 +0000
307+++ src/wlapplication.cc 2013-03-30 12:54:23 +0000
308@@ -840,11 +840,7 @@
309 s.get_int("yres", YRES),
310 s.get_int("depth", 16),
311 s.get_bool("fullscreen", false),
312-#if USE_OPENGL
313 s.get_bool("opengl", true));
314-#else
315- false);
316-#endif
317 }
318
319 /**
320@@ -869,9 +865,7 @@
321
322 m_gfx_fullscreen = s.get_bool("fullscreen", false);
323
324-#if USE_OPENGL
325 m_gfx_opengl = s.get_bool("opengl", true);
326-#endif
327
328 // KLUDGE!
329 // Without this the following config options get dropped by check_used().
330@@ -1203,7 +1197,6 @@
331 }
332
333 if (m_commandline.count("opengl")) {
334-#ifdef USE_OPENGL
335 if (m_commandline["opengl"].compare("0") == 0) {
336 g_options.pull_section("global").create_val("opengl", "false");
337 } else if (m_commandline["opengl"].compare("1") == 0) {
338@@ -1211,9 +1204,6 @@
339 } else {
340 log ("Invalid option opengl=[0|1]\n");
341 }
342-#else
343- log("WARNIG: This version was compiled without support for OpenGL\n");
344-#endif
345 m_commandline.erase("opengl");
346 }
347
348@@ -1419,12 +1409,10 @@
349 " --depth=[16|32] Color depth in number of bits per pixel.\n"
350 " --xres=[...] Width of the window in pixel.\n"
351 " --yres=[...] Height of the window in pixel.\n")
352-#if USE_OPENGL
353 <<
354 _
355 (" --opengl=[0|1]\n"
356 " Enables OpenGL rendering\n")
357-#endif
358 <<
359 _
360 ("\n"
361
362=== modified file 'src/wui/mapview.cc'
363--- src/wui/mapview.cc 2013-02-10 19:36:24 +0000
364+++ src/wui/mapview.cc 2013-03-30 12:54:23 +0000
365@@ -99,11 +99,9 @@
366 egbase.map().overlay_manager().load_graphics();
367
368 if (!m_renderer) {
369-#ifdef USE_OPENGL
370 if (g_opengl) {
371 m_renderer.reset(new GameRendererGL());
372 } else
373-#endif
374 {
375 m_renderer.reset(new GameRendererSDL());
376 }

Subscribers

People subscribed via source and target branches

to status/vote changes: