[Add] Screenshot key.
This commit is contained in:
parent
25d0b29aea
commit
862cd92a7f
9
README
9
README
@ -49,7 +49,12 @@ External View:
|
||||
Special:
|
||||
~~~~~~~~
|
||||
|
||||
ctrl-q - quit.
|
||||
i - show some ugly debug info.
|
||||
ctrl-q - quit.
|
||||
i - show some ugly debug info.
|
||||
ctrl-prntscrn - Screenshot.
|
||||
F11 - Fullscreen.
|
||||
F12 - Add a ship.
|
||||
shift-F12 - Add a station.
|
||||
F9 - Quicksave.
|
||||
|
||||
|
||||
|
25
src/main.cpp
25
src/main.cpp
@ -93,6 +93,7 @@ void L3D::Init(IniConfig& config) {
|
||||
}
|
||||
}
|
||||
|
||||
SDL_WM_SetCaption("Lephisto", "Lephisto"); /* It's about time we name our application window.. */
|
||||
L3D::scrWidth = width;
|
||||
L3D::scrHeight = height;
|
||||
L3D::scrAspect = width / (float)height;
|
||||
@ -154,6 +155,23 @@ void L3D::SetView(View* v) {
|
||||
currentView->ShowAll();
|
||||
}
|
||||
|
||||
void Screendump(char* destFile) {
|
||||
const int W = L3D::GetScrHeight();
|
||||
const int H = L3D::GetScrWidth();
|
||||
char pixel_data[3*W*H];
|
||||
short TGAhead[] = { 0, 2, 0, 0, 0, 0, W, H, 24 };
|
||||
FILE* out = fopen(destFile, "w");
|
||||
if(!out) goto error;
|
||||
glReadBuffer(GL_FRONT);
|
||||
glReadPixels(0, 0, W, H, GL_BGR, GL_UNSIGNED_BYTE, pixel_data);
|
||||
if(fwrite(&TGAhead, sizeof(TGAhead), 3, out) != 3) goto error;
|
||||
if(fwrite(pixel_data, 3*W*H, 1, out) != 1) goto error;
|
||||
fclose(out);
|
||||
return;
|
||||
error:
|
||||
printf("Failed to write screendump.\n");;
|
||||
}
|
||||
|
||||
void L3D::HandleEvents(void) {
|
||||
SDL_Event event;
|
||||
|
||||
@ -164,6 +182,13 @@ void L3D::HandleEvents(void) {
|
||||
case SDL_KEYDOWN:
|
||||
if(KeyState(SDLK_LCTRL) && (event.key.keysym.sym == SDLK_q)) L3D::Quit();
|
||||
if(event.key.keysym.sym == SDLK_i) L3D::showDebugInfo = !L3D::showDebugInfo;
|
||||
if((event.key.keysym.sym == SDLK_PRINT) && KeyState(SDLK_LCTRL)) {
|
||||
char buf[256];
|
||||
const time_t t = time(0);
|
||||
struct tm* _tm = localtime(&t);
|
||||
strftime(buf, sizeof(buf), "screenshot-%Y%m%d-%h%M%S.tga", _tm);
|
||||
Screendump(buf);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if(event.key.keysym.sym == SDLK_F12) {
|
||||
matrix4x4d m; L3D::player->GetRotMatrix(m);
|
||||
|
Loading…
Reference in New Issue
Block a user