int main(int argc, char **argv) { int i; char *git_path; char *tmp; unsigned int gti_speed; draw_fn_t draw_fn; tmp = getenv("GTI_SPEED"); if (!tmp || sscanf(tmp, "%u", >i_speed) != 1) { gti_speed = GTI_SPEED; } open_term(); TERM_WIDTH = term_width(); FRAME_TIME = 1000 * 1000 * 10 / (gti_speed + TERM_WIDTH + 1); draw_fn = select_command(argc, argv); init_space(); for (i = -20; i < TERM_WIDTH; i++) { draw_fn(i); clear_car(i); } move_to_top(); fflush(TERM_FH); git_path = getenv("GIT"); if (git_path) { execv(git_path, argv); } else { execvp(GIT_NAME, argv); } /* error in exec if we land here */ perror(GIT_NAME); return 1; }
void window::paint(HDC hdc) { if (draw_fn != nullptr) { draw_fn(this); } HDC memdc = CreateCompatibleDC(nullptr); if (memdc == nullptr) { panic(L"Couldn't create DC.", hwnd); } HBITMAP bmp = CreateBitmap(width, height, 1, 32, buf.data()); if (bmp == nullptr) { panic(L"Couldn't create bitmap.", hwnd); } SelectObject(memdc, bmp); BitBlt(hdc, 0, 0, width, height, memdc, 0, 0, SRCCOPY); DeleteObject(bmp); DeleteObject(memdc); WCHAR fps[256]; int count = swprintf_s(&fps[0], 256, L"FPS: %.02f FOV: %.f", frame_rate, m_fov); TextOut(hdc, 0, 0, fps, count); }