142
145
logmill = new RLogMill(logfile);
146
147
if(exporter!=0) setFrameExporter(exporter, gGourceSettings.output_framerate);
148
149
//if recording a video or in demo mode, or multiple repos, the slider is initially hidden
251
251
draw(runtime, scaled_dt);
253
253
//extract frames based on frameskip setting if frameExporter defined
254
if(frameExporter != 0 && commitlog && !shutdown) {
254
if(frameExporter != 0 && commitlog && !gGourceSettings.shutdown) {
255
255
if(framecount % (frameskip+1) == 0) {
256
256
frameExporter->dump();
289
void Gource::grabMouse(bool grab_mouse) {
290
this->grab_mouse = grab_mouse;
292
#if SDL_VERSION_ATLEAST(2,0,0)
294
if(!SDL_GetRelativeMouseMode()) {
295
// NOTE: SDL_SetWindowGrab needed as well to work around this bug:
296
// http://bugzilla.libsdl.org/show_bug.cgi?id=1967
298
SDL_SetWindowGrab(display.sdl_window, SDL_TRUE);
299
SDL_SetRelativeMouseMode(SDL_TRUE);
302
if(SDL_GetRelativeMouseMode()) {
303
SDL_SetWindowGrab(display.sdl_window, SDL_FALSE);
304
SDL_SetRelativeMouseMode(SDL_FALSE);
309
#if not SDL_VERSION_ATLEAST(2,0,0)
311
// restore old mouse position
312
SDL_WarpMouse(mousepos.x, mousepos.y);
316
cursor.showCursor(!grab_mouse);
289
319
void Gource::mouseMove(SDL_MouseMotionEvent *e) {
290
320
if(commitlog==0) return;
291
321
if(gGourceSettings.hide_mouse) return;
293
bool rightmouse = cursor.rightButtonPressed();
295
#if not SDL_VERSION_ATLEAST(1,3,0)
324
#if not SDL_VERSION_ATLEAST(2,0,0)
297
325
int warp_x = display.width/2;
298
326
int warp_y = display.height/2;
301
329
if(e->x == warp_x && e->y == warp_y) return;
303
331
SDL_WarpMouse(warp_x, warp_y);
335
bool rightmouse = cursor.rightButtonPressed();
307
337
//move camera in direction the user dragged the mouse
308
338
if(mousedragged || rightmouse) {
366
396
camera.setDistance(distance);
369
#if SDL_VERSION_ATLEAST(1,3,0)
399
#if SDL_VERSION_ATLEAST(2,0,0)
370
400
void Gource::mouseWheel(SDL_MouseWheelEvent *e) {
372
int mouse_x, mouse_y;
373
SDL_GetMouseState(&mouse_x, &mouse_y);
375
vec2 mousepos(mouse_x, mouse_y);
403
428
if(e->button == SDL_BUTTON_LEFT || e->button == SDL_BUTTON_RIGHT) {
404
429
if(!cursor.buttonPressed()) {
406
#if SDL_VERSION_ATLEAST(1,3,0)
407
SDL_SetRelativeMouseMode(SDL_FALSE);
408
SDL_WarpMouseInWindow(display.sdl_window, mousepos.x, mousepos.y);
410
SDL_WarpMouse(mousepos.x, mousepos.y);
412
cursor.showCursor(true);
417
435
if(e->type != SDL_MOUSEBUTTONDOWN) return;
438
#if not SDL_VERSION_ATLEAST(2,0,0)
420
440
if(e->button == SDL_BUTTON_WHEELUP) {
437
458
if(e->button == SDL_BUTTON_RIGHT) {
438
cursor.showCursor(false);
440
#if SDL_VERSION_ATLEAST(1,3,0)
441
SDL_SetRelativeMouseMode(SDL_TRUE);
617
634
if (e->type == SDL_KEYDOWN) {
619
#if SDL_VERSION_ATLEAST(1,3,0)
620
bool key_escape = e->keysym.scancode == SDL_SCANCODE_ESCAPE;
621
bool key_tab = e->keysym.scancode == SDL_SCANCODE_TAB;
622
bool key_space = e->keysym.scancode == SDL_SCANCODE_SPACE;
623
bool key_plus = e->keysym.scancode == SDL_SCANCODE_EQUALS;
624
bool key_equals = e->keysym.scancode == SDL_SCANCODE_EQUALS;
625
bool key_minus = e->keysym.scancode == SDL_SCANCODE_MINUS;
626
bool key_leftbracket = e->keysym.scancode == SDL_SCANCODE_LEFTBRACKET;
627
bool key_rightbracket = e->keysym.scancode == SDL_SCANCODE_RIGHTBRACKET;
628
bool key_comma = e->keysym.scancode == SDL_SCANCODE_COMMA;
629
bool key_period = e->keysym.scancode == SDL_SCANCODE_PERIOD;
630
bool key_slash = e->keysym.scancode == SDL_SCANCODE_SLASH;
637
#if SDL_VERSION_ATLEAST(2,0,0)
638
bool key_escape = e->keysym.sym == SDLK_ESCAPE;
639
bool key_tab = e->keysym.sym == SDLK_TAB;
640
bool key_space = e->keysym.sym == SDLK_SPACE;
641
bool key_plus = e->keysym.sym == SDLK_PLUS;
642
bool key_equals = e->keysym.sym == SDLK_EQUALS;
643
bool key_minus = e->keysym.sym == SDLK_MINUS;
644
bool key_leftbracket = e->keysym.sym == SDLK_LEFTBRACKET;
645
bool key_rightbracket = e->keysym.sym == SDLK_RIGHTBRACKET;
646
bool key_comma = e->keysym.sym == SDLK_COMMA;
647
bool key_period = e->keysym.sym == SDLK_PERIOD;
648
bool key_slash = e->keysym.sym == SDLK_SLASH;
632
650
bool key_escape = e->keysym.unicode == SDLK_ESCAPE;
633
651
bool key_tab = e->keysym.unicode == SDLK_TAB;
1086
1103
//debugLog("readLog()\n");
1088
1105
// read commits until either we are ahead of currtime
1089
while(!commitlog->isFinished() && (commitqueue.empty() || (commitqueue.back().timestamp <= currtime && commitqueue.size() < commitqueue_max_size)) ) {
1106
while((commitlog->hasBufferedCommit() || !commitlog->isFinished()) && (commitqueue.empty() || (commitqueue.back().timestamp <= currtime && commitqueue.size() < commitqueue_max_size)) ) {
1091
1108
RCommit commit;
1100
commitqueue.push_back(commit);
1117
if(gGourceSettings.stop_timestamp != 0 && commit.timestamp > gGourceSettings.stop_timestamp) {
1118
stop_position_reached = true;
1122
commitqueue.push_back(commit);
1103
1125
if(first_read && commitqueue.empty()) {
1114
1136
bool is_finished = commitlog->isFinished();
1116
if( (gGourceSettings.stop_at_end && is_finished)
1117
|| (gGourceSettings.stop_position > 0.0 && commitlog->isSeekable() && (is_finished || last_percent >= gGourceSettings.stop_position)) ) {
1141
(gGourceSettings.stop_at_end && is_finished)
1143
// stop position reached
1144
|| (gGourceSettings.stop_position > 0.0 && commitlog->isSeekable() && (is_finished || last_percent >= gGourceSettings.stop_position))
1118
1146
stop_position_reached = true;
1552
1580
bool up = false;
1553
1581
bool down = false;
1555
#if SDL_VERSION_ATLEAST(1,3,0)
1556
Uint8 *keystate = SDL_GetKeyboardState(0);
1583
#if SDL_VERSION_ATLEAST(2,0,0)
1584
const Uint8 *keystate = SDL_GetKeyboardState(0);
1558
1586
right = keystate[SDL_SCANCODE_RIGHT];
1559
1587
left = keystate[SDL_SCANCODE_LEFT];
2150
2178
void Gource::screenshot() {
2152
2180
//get next free recording name
2154
2182
struct stat finfo;
2157
while(tgano < 10000) {
2158
snprintf(tganame, 256, "gource-%04d.tga", tgano);
2159
if(stat(tganame, &finfo) != 0) break;
2185
while(pngno < 10000) {
2186
snprintf(pngname, 256, "gource-%04d.png", pngno);
2187
if(stat(pngname, &finfo) != 0) break;
2164
std::string filename(tganame);
2166
TGAWriter tga(gGourceSettings.transparent ? 4 : 3);
2167
tga.screenshot(filename);
2169
setMessage("Wrote screenshot %s", tganame);
2192
std::string filename(pngname);
2194
PNGWriter png(gGourceSettings.transparent ? 4 : 3);
2195
png.screenshot(filename);
2197
setMessage("Wrote screenshot %s", pngname);
2172
2200
void Gource::updateVBOs(float dt) {
2675
2699
mousemoved=false;
2676
2700
mouseclicked=false;
2702
if(take_screenshot) {
2704
take_screenshot = false;
2707
if(message_timer > 0.0f) {
2708
font.setColour(vec4(1.0f));
2710
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2712
glEnable(GL_TEXTURE_2D);
2714
font.draw(1, 3, message);