Differences From Artifact [67dd855e73]:
- File
src/Cube.m
— part of check-in
[75e920ae30]
at
2025-03-29 14:25:43
on branch trunk
— Switch from clang-format to manual formatting
clang-format does too many weird things. (user: js, size: 9409) [annotate] [blame] [check-ins using]
To Artifact [4173147859]:
- File src/Cube.m — part of check-in [c634a689e7] at 2025-03-29 17:13:40 on branch trunk — More style fixes (user: js, size: 9295) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
123 124 125 126 127 128 129 | _height = 1080; } } log(@"video: mode"); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if ((_window = SDL_CreateWindow("cube engine", | | < | | < | 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, _width, _height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | (!windowed ? SDL_WINDOW_FULLSCREEN : 0))) == 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 | [self quit]; break; case SDL_KEYDOWN: case SDL_KEYUP: if (_repeatsKeys || event.key.repeat == 0) keypress(event.key.keysym.sym, | | | | 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)); break; case SDL_TEXTINPUT: input(@(event.text.text)); break; case SDL_MOUSEMOTION: if (ignore) { ignore--; |
︙ | ︙ | |||
301 302 303 304 305 306 307 | - (void)screenshot { SDL_Surface *image; SDL_Surface *temp; if ((image = SDL_CreateRGBSurface(SDL_SWSURFACE, _width, _height, 24, | | | < | | < | 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) { if ((temp = SDL_CreateRGBSurface(SDL_SWSURFACE, _width, _height, 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), 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 | // failure exit void fatal(OFConstantString *s, ...) { va_list args; va_start(args, s); OFMutableString *msg = [[OFMutableString alloc] initWithFormat: s | | | 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]; va_end(args); [msg appendFormat: @" (%s)\n", SDL_GetError()]; [Cube.sharedInstance showMessage: msg]; [OFApplication terminateWithStatus: 1]; } |
︙ | ︙ |