annotate mde/setup/Screen.d @ 137:9f035cd139c6

BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed. Content restrutured a lot: New IContent module, Content module includes more functionality. New ContentLoader module to manage content loading/saving/translation. Translation module moved to content dir and cut down to reflect current usage. File format unchanged except renames: FontOptions -> Font, VideoOptions -> Screen. Font render mode and LCD filter options are now enums. GUI loading needs to create content (and set type for enums), but doesn't save/load value. Some setup of mainSchedule moved to mde.mainLoop. Content callbacks are called on content change now. ContentLists are set up implicitly from content symbols. Not as fast but much easier! Bug-fix in the new MTTagReader. Renamed MT *Reader maker functions to avoid confusion in paths.d. New mde.setup.logger module to allow logger setup before any other module's static this().
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 07 Feb 2009 12:46:03 +0000
parents 5ee69b3ed9c9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
1 /* LICENSE BLOCK
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
2 Part of mde: a Modular D game-oriented Engine
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
4
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify it under the terms
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
6 of the GNU General Public License as published by the Free Software Foundation, either
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
7 version 2 of the License, or (at your option) any later version.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
8
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
11 See the GNU General Public License for more details.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
12
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
13 You should have received a copy of the GNU General Public License
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
15
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
16 /** Screen: SDL & OpenGL setup/cleanup, drawing.
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
17 *
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
18 * Has an interface by which other code can hook in for drawing and resize notifications. */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
19 module mde.setup.Screen;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
20
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
21 import mde.setup.exception;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
22 import mde.content.AStringContent;
36
57d000574d75 Enabled drawing on demand, and made the polling interval configurable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 33
diff changeset
23 import imde = mde.imde;
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
24 debug (drawGlyphCache) import mde.font.font;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
25
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
26 import tango.util.log.Log : Log, Logger;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
27 import tango.stdc.stringz;
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
28 import tango.time.Time; // TimeSpan (type only; unused)
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
29
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
30 import derelict.sdl.sdl;
97
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
31 import derelict.opengl.gl;
48
a98ffb64f066 Implemented font rendering (grayscale only; i.e. non-LCD).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
32 import derelict.util.exception;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
33
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
34 /** Currently just used as a namespace. Potential for multiple screen support later? */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
35 struct Screen {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
36 // TYPES (these mustn't be static):
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
37 /** Interface for anything hooking into the screen for drawing, etc. */
86
79d816b3e2d2 New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
38 interface IDrawable {
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
39 /** Called on window creation and whenever the window manager resizes the window, before
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
40 * the new size is set. The new size is passed.
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
41 *
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
42 * The parameters were passed as ref to allow the called function to change them, but SDL
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
43 * didn't appear able to resize the window (on X11), so this was dropped. */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
44 void sizeEvent (int w, int h);
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
45
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
46 /** Called you guess when :-) */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
47 void draw ();
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
48 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
49
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
50 static:
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
51 /** Init function to initialize SDL. */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
52 StageState init () { // init func
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
53 // Initialise SDL
116
5ee69b3ed9c9 Partial implementation of infinite widget recursion protection; some cleanup.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 104
diff changeset
54 debug (SDLCalls) logger.trace ("Calling SDL_Init (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK)");
97
30470bc19ca4 Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
55 if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK /+| SDL_INIT_EVENTTHREAD+/)) {
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
56 logger.fatal ("SDL initialisation failed:");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
57 char* msg = SDL_GetError ();
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
58 logger.fatal (msg ? fromStringz(msg) : "no reason available");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
59
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
60 throw new InitException ("SDL Initialization failed");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
61 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
62 return StageState.ACTIVE;
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
63 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
64 /** SDL shutdown */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
65 StageState cleanup () {
116
5ee69b3ed9c9 Partial implementation of infinite widget recursion protection; some cleanup.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 104
diff changeset
66 debug (SDLCalls) logger.trace ("Calling SDL_Quit ()");
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
67 SDL_Quit();
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
68 return StageState.INACTIVE;
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
69 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
70 /** Init function to set up a window with OpenGL support. */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
71 StageState initWindow () {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
72 //BEGIN Create window and initialize OpenGL
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
73 // Window creation flags and size
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
74 flags = SDL_OPENGL;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
75 if (hardware()) flags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
76 else flags |= SDL_SWSURFACE;
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
77 int w, h;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
78 if (fullscreen()) {
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
79 flags |= SDL_FULLSCREEN;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
80 w = screenW();
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
81 h = screenH();
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
82 }
48
a98ffb64f066 Implemented font rendering (grayscale only; i.e. non-LCD).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
83 else {
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
84 if (resizable()) flags |= SDL_RESIZABLE;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
85 if (noFrame()) flags |= SDL_NOFRAME;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
86 w = windowW();
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
87 h = windowH();
48
a98ffb64f066 Implemented font rendering (grayscale only; i.e. non-LCD).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
88 }
a98ffb64f066 Implemented font rendering (grayscale only; i.e. non-LCD).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
89
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
90 // OpenGL attributes
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
91 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
92 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
93 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
94 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
95 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
96
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
97 // Open a window
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
98 if (setWindow (w, h)) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
99 throw new InitException ("Failed to open a window");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
100 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
101
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
102 /* Now (must be done after GL context is created) we can try to load later version.
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
103 * The initial loading provides opengl 1.1 features.
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
104 *
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
105 * 1.4 is now used for glBlendColor (coloured text).
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
106 *
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
107 * Currently the latest version used is 1.3; adjust this as necessary. However, before using
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
108 * features from any OpenGL version > 1.1 a check must be made on what was loaded by calling
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
109 * DerelictGL.availableVersion(). Note that availableVersion() could be used instead to load
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
110 * the highest supported version but this way we know what we're getting. */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
111 if (DerelictGL.availableVersion < GLVersion.Version13) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
112 throw new InitException ("Required at least OpenGL 1.3; didn't get this.");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
113 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
114 /+try {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
115 DerelictGL.loadVersions(GLVersion.Version14);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
116 } catch (SharedLibProcLoadException e) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
117 logger.warn ("Loading OpenGL version 1.4 failed:");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
118 logger.warn (e.msg);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
119
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
120 setInitFailure ();
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
121 return;
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
122 }+/
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
123
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
124 // OpenGL stuff:
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
125 glDisable(GL_LIGHTING);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
126 glDisable(GL_DEPTH_TEST);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
127 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
128 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
129 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
130 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
131 glShadeModel(GL_SMOOTH);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
132
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
133 glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
134
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
135 glMatrixMode(GL_MODELVIEW);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
136 glLoadIdentity();
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
137
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
138 // Used for font rendering:
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
139 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
140 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
141 //NOTE: wrap mode may have an effect, but shouldn't be noticed...
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
142
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
143 // Window-manager settings
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
144 SDL_WM_SetCaption (toStringz ("mde"), null);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
145 // SDL_WM_GrabInput (use later)
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
146 //END Create window and initialize OpenGL
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
147 return StageState.ACTIVE;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
148 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
149
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
150
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
151 /** Called when a resize event occurs (when the window manager resizes the window). */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
152 void resizeEvent (int w, int h) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
153 // Save new size to config
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
154 if (fullscreen()) { // probably resizeEvent only called when not fullscreen
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
155 screenW = w;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
156 screenH = h;
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
157 } else {
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
158 windowW = w;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
159 windowH = h;
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
160 }
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
161
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
162 if (setWindow (w,h))
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
163 imde.run = false;
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
164 }
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
165
86
79d816b3e2d2 New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
166 /** Add a drawable element to the screen (see IDrawable interface).
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
167 *
86
79d816b3e2d2 New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
168 * Should be called before Init to get the initial size (sizeEvent is only called when the size
79d816b3e2d2 New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
169 * is set). Currently no means to remove drawables, and not really designed for more than one.
79d816b3e2d2 New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
170 */
79d816b3e2d2 New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
171 void addDrawable (IDrawable d) {
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
172 drawables ~= d;
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
173 }
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
174
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
175 /** Drawing function */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
176 void draw (TimeSpan) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
177 glClear(GL_COLOR_BUFFER_BIT);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
178
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
179 foreach (d; drawables) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
180 try {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
181 d.draw;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
182 } catch (Exception e) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
183 logger.error ("Drawable failed to draw: "~e.msg);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
184 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
185 }
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
186
86
79d816b3e2d2 New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
187 debug (drawGlyphCache) FontStyle.drawTexture;
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
188
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
189 // Error check:
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
190 GLenum err = glGetError();
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
191 while (err != GL_NO_ERROR) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
192 logger.error ("GL error: {}", err);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
193 err = glGetError();
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
194 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
195
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
196 glFinish(); // Use Finish rather than Flush to make sure gl is ready to swap buffers
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
197 SDL_GL_SwapBuffers();
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
198 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
199
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
200 /** Set a new window size. Returns true on failure due to the different ways this must be
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
201 * handled. */
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
202 private bool setWindow (int w, int h) {
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
203 foreach (d; drawables) { // Tell all drawables the new window size.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
204 try {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
205 d.sizeEvent (w,h);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
206 } catch (Exception e) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
207 logger.error ("Drawable failed while setting size: "~e.msg);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
208 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 86
diff changeset
209 }
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
210
86
79d816b3e2d2 New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
211 //debug logger.trace ("Setting video mode {}x{}, 32-bit, flags: {}", w,h,flags);
116
5ee69b3ed9c9 Partial implementation of infinite widget recursion protection; some cleanup.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 104
diff changeset
212 debug (SDLCalls) logger.trace ("Calling SDL_SetVideoMode ({}, {}, 32, 0x{:x})", w,h, flags);
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
213 if (SDL_SetVideoMode (w, h, 32, flags) is null) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
214 logger.fatal ("Unable to set video mode:");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
215 char* msg = SDL_GetError ();
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
216 logger.fatal (msg ? fromStringz(msg) : "no reason available");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
217
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
218 // Print a load of info:
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
219 logger.info ("Available video modes:");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
220 SDL_Rect** modes = SDL_ListModes (null, SDL_FULLSCREEN);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
221 if (modes is null) logger.info ("None!");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
222 else if (modes is cast(SDL_Rect**) -1) logger.info ("All modes are available");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
223 else {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
224 for (uint i = 0; modes[i] !is null; ++i) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
225 logger.info ("\t{}x{}", modes[i].w, modes[i].h);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
226 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
227 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
228
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
229 SDL_VideoInfo* vi = SDL_GetVideoInfo ();
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
230 if (vi !is null) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
231 logger.info ("Video info:");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
232 logger.info ("Hardware surface support: "~ (vi.flags & SDL_HWSURFACE ? "yes" : "no"));
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
233 logger.info ("Video memory: {}", vi.video_mem);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
234
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
235 if (vi.vfmt !is null) {
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
236 logger.info ("Best video mode:");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
237 logger.info ("Bits per pixel: {}", vi.vfmt.BitsPerPixel);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
238 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
239 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
240
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
241 return true;
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
242 }
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
243
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
244 // Reset the projection and viewport
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
245 glMatrixMode (GL_PROJECTION);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
246 glLoadIdentity ();
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
247
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
248 glViewport (0,0,w,h);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
249
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
250 // Make the top-left the origin (see gui/GUI notes.txt):
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
251 // Note that this only affects vertex operations − direct rasterisation operations are
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
252 // unaffected!
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
253 glOrtho (0.0,w, h,0.0, -1.0, 1.0);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
254
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
255 glMatrixMode(GL_MODELVIEW);
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
256 return false;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
257 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
258
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
259 static this() {
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
260 logger = Log.getLogger ("mde.setup.Screen");
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
261
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
262 fullscreen = new BoolContent ("Screen.fullscreen");
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
263 hardware = new BoolContent ("Screen.hardware");
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
264 resizable = new BoolContent ("Screen.resizable");
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
265 noFrame = new BoolContent ("Screen.noFrame");
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
266 screenW = new IntContent ("Screen.screenW");
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
267 screenH = new IntContent ("Screen.screenH");
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
268 windowW = new IntContent ("Screen.windowW");
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
269 windowH = new IntContent ("Screen.windowH");
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
270 }
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
271
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
272 // DATA:
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
273 private:
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
274 uint flags = 0;
86
79d816b3e2d2 New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
275 IDrawable[] drawables;
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
276 Logger logger;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
277
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
278 // Option values:
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
279 BoolContent fullscreen, hardware, resizable, noFrame;
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
280 IntContent screenW,screenH, windowW,windowH;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
281 }