Skip to content

Commit 7be848c

Browse files
committed
example updates
1 parent 2ab0065 commit 7be848c

4 files changed

Lines changed: 14 additions & 8 deletions

File tree

Examples/OnlineSession/OnlineSession.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ static void handle_frame_time(
2222
uint64_t frame_end = SDL_GetPerformanceCounter();
2323
frame_time_ns = ((frame_end - frame_start) * 1000000000) / perf_freq;
2424
if (frame_delay_ns > frame_time_ns) {
25-
uint64_t delay_ns = frames_ahead > .5f ? frame_delay_ns * 1.016 : frame_delay_ns - frame_time_ns;
25+
uint64_t delay_ns = frames_ahead > .5f ? frame_delay_ns * 1.016 : frame_delay_ns;
26+
delay_ns -= frame_time_ns;
2627
SDL_DelayNS(delay_ns);
2728
}
2829
}
@@ -94,7 +95,7 @@ int main(int argc, char* argv[]) {
9495
// gekkonet setup
9596
GekkoSession* session = nullptr;
9697

97-
gekko_create(&session, GekkoSessionType::GekkoGameSession);
98+
gekko_create(&session, GekkoGameSession);
9899

99100
GekkoConfig config{};
100101

@@ -214,14 +215,16 @@ int main(int argc, char* argv[]) {
214215

215216
gs.Draw(renderer);
216217

218+
float frames_ahead = gekko_frames_ahead(session);
219+
217220
if (remote_handle >= 0) {
218221
GekkoNetworkStats netstats = {};
219222
gekko_network_stats(session, remote_handle, &netstats);
220223
char title[256];
221224
snprintf(title, sizeof(title),
222-
"Pong | P: %ums PA: %.1fms J: %.1fms | S: %.2f R: %.2f KB/s",
225+
"Pong | P: %ums PA: %.1fms J: %.1fms | S: %.2f R: %.2f KB/s | FA: %.2f",
223226
netstats.last_ping, netstats.avg_ping, netstats.jitter,
224-
netstats.kb_sent, netstats.kb_received);
227+
netstats.kb_sent, netstats.kb_received, frames_ahead);
225228
SDL_SetWindowTitle(window, title);
226229
}
227230

@@ -230,7 +233,7 @@ int main(int argc, char* argv[]) {
230233
frame_time_ns,
231234
frame_delay_ns,
232235
performance_frequency,
233-
gekko_frames_ahead(session)
236+
frames_ahead
234237
);
235238
}
236239

Examples/Sliders/Sliders.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ static void handle_frame_time(
8181
uint64_t frame_end = SDL_GetPerformanceCounter();
8282
frame_time_ns = ((frame_end - frame_start) * 1000000000) / perf_freq;
8383
if (frame_delay_ns > frame_time_ns) {
84-
uint64_t delay_ns = frames_ahead > 1.f ? frame_delay_ns * 1.016 : frame_delay_ns - frame_time_ns;
84+
uint64_t delay_ns = frames_ahead > .5f ? frame_delay_ns * 1.016 : frame_delay_ns;
85+
delay_ns -= frame_time_ns;
8586
SDL_DelayNS(delay_ns);
8687
}
8788
}

Examples/SpectatorSession/SpectatorSession.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ static void handle_frame_time(
2222
uint64_t frame_end = SDL_GetPerformanceCounter();
2323
frame_time_ns = ((frame_end - frame_start) * 1000000000) / perf_freq;
2424
if (frame_delay_ns > frame_time_ns) {
25-
uint64_t delay_ns = frames_ahead > .5f ? frame_delay_ns * 1.016 : frame_delay_ns - frame_time_ns;
25+
uint64_t delay_ns = frames_ahead > .5f ? frame_delay_ns * 1.016 : frame_delay_ns;
26+
delay_ns -= frame_time_ns;
2627
SDL_DelayNS(delay_ns);
2728
}
2829
}

Examples/StressSession/StressSession.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ static void handle_frame_time(
2222
uint64_t frame_end = SDL_GetPerformanceCounter();
2323
frame_time_ns = ((frame_end - frame_start) * 1000000000) / perf_freq;
2424
if (frame_delay_ns > frame_time_ns) {
25-
uint64_t delay_ns = frames_ahead > .5f ? frame_delay_ns * 1.016 : frame_delay_ns - frame_time_ns;
25+
uint64_t delay_ns = frames_ahead > .5f ? frame_delay_ns * 1.016 : frame_delay_ns;
26+
delay_ns -= frame_time_ns;
2627
SDL_DelayNS(delay_ns);
2728
}
2829
}

0 commit comments

Comments
 (0)