| ... | ... |
@@ -84,6 +84,18 @@ togglezoom(Uxn *u) |
| 84 | 84 |
redraw(u); |
| 85 | 85 |
} |
| 86 | 86 |
|
| 87 |
+void |
|
| 88 |
+save_screenshot(void) |
|
| 89 |
+{
|
|
| 90 |
+ const Uint32 format = SDL_PIXELFORMAT_ARGB8888; |
|
| 91 |
+ SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom, 32, format); |
|
| 92 |
+ SDL_LockSurface(surface); |
|
| 93 |
+ SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch); |
|
| 94 |
+ SDL_UnlockSurface(surface); |
|
| 95 |
+ SDL_SaveBMP(surface, "screenshot.bmp"); |
|
| 96 |
+ SDL_FreeSurface(surface); |
|
| 97 |
+} |
|
| 98 |
+ |
|
| 87 | 99 |
void |
| 88 | 100 |
quit(void) |
| 89 | 101 |
{
|
| ... | ... |
@@ -178,7 +190,9 @@ doctrl(Uxn *u, SDL_Event *event, int z) |
| 178 | 190 |
toggledebug(u); |
| 179 | 191 |
if(SDL_GetModState() & KMOD_LALT) |
| 180 | 192 |
togglezoom(u); |
| 181 |
- } |
|
| 193 |
+ } else if(z && event->key.keysym.sym == SDLK_s) |
|
| 194 |
+ if(SDL_GetModState() & KMOD_LCTRL) |
|
| 195 |
+ save_screenshot(); |
|
| 182 | 196 |
switch(event->key.keysym.sym) {
|
| 183 | 197 |
case SDLK_LCTRL: flag = 0x01; break; |
| 184 | 198 |
case SDLK_LALT: flag = 0x02; break; |