Mercurial > projects > mde
annotate mde/SDL.d @ 21:a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Mon, 24 Mar 2008 17:53:28 +0000 |
parents | 838577503598 |
children | 249eb6620685 |
rev | line source |
---|---|
17
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
1 /* LICENSE BLOCK |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
4 |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
5 This program is free software; you can redistribute it and/or modify it under the terms of |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
6 the GNU General Public License, version 2, as published by the Free Software Foundation. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
7 |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
8 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
9 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
10 See the GNU General Public License for more details. |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
11 |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
12 You should have received a copy of the GNU General Public License along |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
13 with this program; if not, write to the Free Software Foundation, Inc., |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ |
5f90774ea1ef
Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
16
diff
changeset
|
15 |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
16 /** Just a temporary place to put SDL Init and Video stuff. |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
17 */ |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
18 module mde.SDL; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
19 |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
20 import mde.scheduler.InitStage; |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
21 import mde.input.joystick; |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
22 import mde.options; |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
23 |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
24 import tango.util.log.Log : Log, Logger; |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
25 import tango.stdc.stringz; |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
26 |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
27 import derelict.sdl.sdl; |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
28 import derelict.opengl.gl; |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
29 import derelict.util.exception; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
30 |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
31 Logger logger; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
32 static this() { |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
33 logger = Log.getLogger ("mde.SDL"); |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
34 |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
35 init2.addFunc (&initSdlAndGl); |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
36 init4.addFunc (&setupWindow); |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
37 } |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
38 |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
39 void initSdlAndGl() { // init2 func |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
40 logger.trace ("init2: initSdlAndGl() started"); |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
41 |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
42 // Load SDL and GL dynamic libs |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
43 try { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
44 DerelictSDL.load(); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
45 DerelictGL.load(); |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
46 } catch (DerelictException de) { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
47 logger.fatal ("Loading dynamic library failed:"); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
48 logger.fatal (de.msg); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
49 |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
50 setInitFailure (); |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
51 return; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
52 } |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
53 logger.trace ("Derelict: loaded SDL and OpenGL"); |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
54 |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
55 // Initialise SDL |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
56 if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK /+| SDL_INIT_EVENTTHREAD+/)) { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
57 logger.fatal ("SDL initialisation failed:"); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
58 char* msg = SDL_GetError (); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
59 logger.fatal (msg ? fromStringz(msg) : "no reason available"); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
60 |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
61 setInitFailure (); |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
62 return; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
63 } |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
64 |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
65 cleanup2.addFunc (&cleanupSDL); |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
66 logger.trace ("SDL initialised"); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
67 |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
68 // Must be called after SDL has been initialised, so cannot be a separate Init function. |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
69 openJoysticks (); // after SDL init |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
70 cleanup2.addFunc (&closeJoysticks); |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
71 |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
72 logger.trace ("init2: initSdlAndGl() finished"); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
73 } |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
74 |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
75 void setupWindow() { // init4 func |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
76 logger.trace ("init4: setupWindow() started"); |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
77 |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
78 // Window creation flags |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
79 /* NOTE: I'm getting an API mismatch error from the nvidia driver when using OpenGL, |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
80 * thus I've temporarily disabled it. */ |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
81 version (MDE_OPENGL) uint flags = SDL_OPENGL; |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
82 else uint flags = 0; |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
83 if (Options.video.fullscreen) flags |= SDL_FULLSCREEN; |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
84 else { |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
85 if (Options.video.resizable) flags |= SDL_RESIZABLE; |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
86 if (Options.video.noFrame) flags |= SDL_NOFRAME; |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
87 } |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
88 if (Options.video.hardware) flags |= SDL_HWSURFACE | SDL_DOUBLEBUF; |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
89 else flags |= SDL_SWSURFACE; |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
90 |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
91 version (MDE_OPENGL) { |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
92 // OpenGL attributes |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
93 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
94 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
95 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
96 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
97 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
98 } |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
99 |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
100 // Open a window |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
101 if (SDL_SetVideoMode (Options.video.width, Options.video.height, 32, flags) is null) { |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
102 logger.fatal ("Unable to set video mode:"); |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
103 char* msg = SDL_GetError (); |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
104 logger.fatal (msg ? fromStringz(msg) : "no reason available"); |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
105 |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
106 setInitFailure (); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
107 return; |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
108 } |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
109 |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
110 // Window-manager settings |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
111 SDL_WM_SetCaption (toStringz ("mde"), null); |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
112 // SDL_WM_GrabInput (use later) |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
113 |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
114 logger.trace ("init4: setupWindow() finished"); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
115 } |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
116 |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
117 void cleanupSDL () { // cleanup2 func |
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
118 logger.trace ("cleanup2: cleanupSDL() started"); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
119 SDL_Quit(); |
21
a60cbb7359dd
Window settings now come from options, and may use OpenGL (enabled/disabled at compile time).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
20
diff
changeset
|
120 logger.trace ("cleanup2: cleanupSDL() finished"); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
121 } |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
122 |
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
123 /+ Load of info-printing stuff (currently doesn't have a use) |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
124 // Print a load of info: |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
125 logger.info ("Available video modes:"); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
126 char[128] tmp; |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
127 SDL_Rect** modes = SDL_ListModes (null, SDL_FULLSCREEN); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
128 if (modes is null) logger.info ("None!"); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
129 else if (modes is cast(SDL_Rect**) -1) logger.info ("All modes are available"); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
130 else { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
131 for (uint i = 0; modes[i] !is null; ++i) { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
132 logger.info (logger.format (tmp, "\t{}x{}", modes[i].w, modes[i].h)); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
133 } |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
134 } |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
135 |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
136 SDL_VideoInfo* vi = SDL_GetVideoInfo (); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
137 if (vi !is null) { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
138 logger.info ("Video info:"); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
139 logger.info ("Hardware surface support: "~ (vi.flags & SDL_HWSURFACE ? "yes" : "no")); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
140 logger.info (logger.format (tmp, "Video memory: {}", vi.video_mem)); |
20
838577503598
Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
17
diff
changeset
|
141 |
16
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
142 if (vi.vfmt !is null) { |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
143 logger.info ("Best video mode:"); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
144 logger.info (logger.format (tmp, "Bits per pixel: {}", vi.vfmt.BitsPerPixel)); |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
145 } |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
146 } |
9cb7b9310168
Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
147 +/ |