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

Proposed by Jens Beyer
Status: Merged
Merged at revision: 6520
Proposed branch: lp:~qcumber-some/widelands/bug704637
Merge into: lp:widelands
Diff against target: 47 lines (+16/-4)
2 files modified
src/constants.h (+4/-0)
src/graphic/graphic.cc (+12/-4)
To merge this branch: bzr merge lp:~qcumber-some/widelands/bug704637
Reviewer Review Type Date Requested Status
SirVer Approve
Jens Beyer Needs Resubmitting
Review via email: mp+150915@code.launchpad.net

Description of the change

Just as hjd proposed in the bug, simply try to fall back to default settings if the other two tries fail.

Interesting "feature" is, that the setting from .config file is still visible in the config screen, while the window is in tiny 640x480. I don't think this is a bug, but you may comment on that.

I don't know if we should tell the user that something's wrong, this could be quite difficult this early in the game. On the other hand, if I am faced by this tiny window, I am definitely looking for the graphics configuration ingame to fix it, so I will see my mistake.

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

Thanks for tackling this!

Move the second check (!sdlsurface) into the first - otherwise you check twice for the same condition. I suggest merging the log's into one. And I suggest making the minimum graphics explicit via some consts in constants.h or widelands.h.

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

Updated as suggested.

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

Cool. One more thing I noticed: when disabling opengl, g_opengl (a global variable) must also be set to false. Can you make sure this is the case here? I think this is then ready for merging - feel free to do it yourself or ping me so I can do it. Thanks for fixing this issue!

And secondly - this will still seem strange to users. They choose one mode but they get a completely different one without noticfication (because most will not read the console output). I have no idea how to solve this properly though - some kind of state must be passed back and conserved till we could display a message box. Well, we can find a solution in another patch for this.

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

I didn't do anything to OpenGL.

If I understand the code correctly, the OpenGL stuff is before, and when we arrive at line 31, in the case of !sdl_surface, opengl is already false anyway, and flags is set &~SDL_OPENGL.

So the handling of the OpenGL stuff is completely untouched by me.

Maybe someone else can check on this, too. If noone objects, I'll merge this tonight.

Revision history for this message
SirVer (sirver) wrote :

I just checked the code and you are right, this does not need any changes to g_opengl. Thanks for caring for this bug!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/constants.h'
2--- src/constants.h 2013-02-11 19:51:33 +0000
3+++ src/constants.h 2013-02-28 15:58:25 +0000
4@@ -41,6 +41,10 @@
5 #define XRES 800 ///< Fullscreen Menu Width
6 #define YRES 600 ///< Fullscreen Menu Height
7
8+#define FALLBACK_GRAPHICS_WIDTH 640
9+#define FALLBACK_GRAPHICS_HEIGHT 480
10+#define FALLBACK_GRAPHICS_DEPTH 16
11+
12 /// \name Fonts
13 /// Font constants, defined including size
14 //@{
15
16=== modified file 'src/graphic/graphic.cc'
17--- src/graphic/graphic.cc 2013-02-16 08:02:26 +0000
18+++ src/graphic/graphic.cc 2013-02-28 15:58:25 +0000
19@@ -119,16 +119,24 @@
20 // If we tried opengl and it was not successful try without opengl
21 if (!sdlsurface and opengl)
22 {
23- log("Graphics: Could not set videomode: %s\n", SDL_GetError());
24- log("Graphics: Trying without opengl\n");
25+ log("Graphics: Could not set videomode: %s, trying without opengl\n", SDL_GetError());
26 flags &= ~SDL_OPENGL;
27 sdlsurface = SDL_SetVideoMode(w, h, bpp, flags);
28 }
29 #endif
30
31 if (!sdlsurface)
32- throw wexception
33- ("Graphics: could not set video mode: %s", SDL_GetError());
34+ {
35+ log
36+ ("Graphics: Could not set videomode: %s, trying minimum graphics settings\n",
37+ SDL_GetError());
38+ flags &= ~SDL_FULLSCREEN;
39+ sdlsurface = SDL_SetVideoMode
40+ (FALLBACK_GRAPHICS_WIDTH, FALLBACK_GRAPHICS_HEIGHT, FALLBACK_GRAPHICS_DEPTH, flags);
41+ if (!sdlsurface)
42+ throw wexception
43+ ("Graphics: could not set video mode: %s", SDL_GetError());
44+ }
45
46 // setting the videomode was successful. Print some information now
47 log("Graphics: Setting video mode was successful\n");

Subscribers

People subscribed via source and target branches

to status/vote changes: