Cube  Diff

Differences From Artifact [67dd855e73]:

To Artifact [4173147859]:


123
124
125
126
127
128
129
130

131
132
133


134
135
136
137
138
139
140
141
123
124
125
126
127
128
129

130



131
132

133
134
135
136
137
138
139







-
+
-
-
-
+
+
-







				_height = 1080;
			}
		}

		log(@"video: mode");
		SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
		if ((_window = SDL_CreateWindow("cube engine",
		         SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
		    SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
		         _width, _height,
		         SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL |
		             (!windowed ? SDL_WINDOW_FULLSCREEN : 0))) ==
		    _width, _height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL |
		    (!windowed ? SDL_WINDOW_FULLSCREEN : 0))) == NULL ||
		        NULL ||
		    SDL_GL_CreateContext(_window) == NULL)
			fatal(@"Unable to create OpenGL screen");

		log(@"video: misc");
		SDL_SetWindowGrab(_window, SDL_TRUE);
		SDL_SetRelativeMouseMode(SDL_TRUE);
		SDL_ShowCursor(0);
240
241
242
243
244
245
246
247
248


249
250
251
252
253
254
255
238
239
240
241
242
243
244


245
246
247
248
249
250
251
252
253







-
-
+
+







					[self quit];
					break;
				case SDL_KEYDOWN:
				case SDL_KEYUP:
					if (_repeatsKeys ||
					    event.key.repeat == 0)
						keypress(event.key.keysym.sym,
						    event.key.state ==
						        SDL_PRESSED);
						    (event.key.state ==
						    SDL_PRESSED));
					break;
				case SDL_TEXTINPUT:
					input(@(event.text.text));
					break;
				case SDL_MOUSEMOTION:
					if (ignore) {
						ignore--;
301
302
303
304
305
306
307
308

309
310

311
312
313
314
315
316
317
318
319


320
321
322
323
324
325
326
327
299
300
301
302
303
304
305

306
307

308
309
310
311
312
313
314



315
316

317
318
319
320
321
322
323







-
+

-
+






-
-
-
+
+
-








- (void)screenshot
{
	SDL_Surface *image;
	SDL_Surface *temp;

	if ((image = SDL_CreateRGBSurface(SDL_SWSURFACE, _width, _height, 24,
	         0x0000FF, 0x00FF00, 0xFF0000, 0)) != NULL) {
	    0x0000FF, 0x00FF00, 0xFF0000, 0)) != NULL) {
		if ((temp = SDL_CreateRGBSurface(SDL_SWSURFACE, _width, _height,
		         24, 0x0000FF, 0x00FF00, 0xFF0000, 0)) != NULL) {
		    24, 0x0000FF, 0x00FF00, 0xFF0000, 0)) != NULL) {
			glReadPixels(0, 0, _width, _height, GL_RGB,
			    GL_UNSIGNED_BYTE, image->pixels);

			for (int idx = 0; idx < _height; idx++) {
				char *dest =
				    (char *)temp->pixels + 3 * _width * idx;
				memcpy(dest,
				    (char *)image->pixels +
				        3 * _width * (_height - 1 - idx),
				memcpy(dest, (char *)image->pixels + 3 *
				    _width * (_height - 1 - idx), 3 * _width);
				    3 * _width);
				endianswap(dest, 3, _width);
			}

			OFString *path = [OFString stringWithFormat:
			    @"screenshots/screenshot_%d.bmp", lastmillis];
			SDL_SaveBMP(temp,
			    [_userDataIRI IRIByAppendingPathComponent: path]
343
344
345
346
347
348
349
350

351
352
353
354
355
356
357
339
340
341
342
343
344
345

346
347
348
349
350
351
352
353







-
+







// failure exit
void
fatal(OFConstantString *s, ...)
{
	va_list args;
	va_start(args, s);
	OFMutableString *msg = [[OFMutableString alloc] initWithFormat: s
	                                                     arguments: args];
							     arguments: args];
	va_end(args);

	[msg appendFormat: @" (%s)\n", SDL_GetError()];

	[Cube.sharedInstance showMessage: msg];
	[OFApplication terminateWithStatus: 1];
}