Skip to content

Commit 3864394

Browse files
committed
Consolidate NDEBUG Checks
1 parent c96c6ee commit 3864394

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/app/Application.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <chrono>
1414
#include <fstream>
1515

16+
#ifndef NDEBUG
17+
#define FLOX_SHOW_DEBUG_INFO
18+
#endif
19+
1620
using namespace lwvl::debug;
1721
using namespace std::chrono;
1822

@@ -94,16 +98,16 @@ int run() {
9498
Window window(width, height, "Ultimate Flox");
9599

96100
lwvl::Program::clear();
97-
#ifndef NDEBUG
101+
#ifdef FLOX_SHOW_DEBUG_INFO
98102
GLEventListener listener(
99103
[](
100104
Source source, Type type,
101105
Severity severity, unsigned int id, int length,
102106
const char *message, const void *userState
103107
) {
104-
//if (type != Type::OTHER){
108+
if (type != Type::OTHER){
105109
std::cout << "[OpenGL] " << message << std::endl;
106-
//}
110+
}
107111
}
108112
);
109113

@@ -165,13 +169,13 @@ int run() {
165169
VisionShader visionShader{projection};
166170
BoidShader *activeShader = &defaultBoidShader;
167171

168-
#ifndef NDEBUG
172+
#ifdef FLOX_SHOW_DEBUG_INFO
169173
std::cout << "Setup took " << delta(setupStart) << " seconds." << std::endl;
170174
#endif
171175
auto secondStart = high_resolution_clock::now();
172176
auto frameStart = high_resolution_clock::now();
173177

174-
#ifndef NDEBUG
178+
#ifdef FLOX_SHOW_DEBUG_INFO
175179
double eventDurationAverage = 0.0;
176180
double updateDurationAverage = 0.0;
177181
double renderDurationAverage = 0.0;
@@ -193,7 +197,7 @@ int run() {
193197
L.validate(onFrameStart.call());
194198
}
195199

196-
#ifndef NDEBUG
200+
#ifdef FLOX_SHOW_DEBUG_INFO
197201
auto averageStart = high_resolution_clock::now();
198202
#endif
199203

@@ -269,9 +273,9 @@ int run() {
269273
}
270274
}
271275

272-
#ifndef NDEBUG
276+
#ifdef FLOX_SHOW_DEBUG_INFO
273277
eventDurationAverage += delta(averageStart);
274-
averageStart = high_resolution_clock::now();
278+
averageStart = high_resolution_clock::now();
275279
#endif
276280

277281
// Update engine
@@ -280,9 +284,9 @@ int run() {
280284
flock.update(algorithm, dt);
281285
}
282286

283-
#ifndef NDEBUG
287+
#ifdef FLOX_SHOW_DEBUG_INFO
284288
updateDurationAverage += delta(averageStart);
285-
averageStart = high_resolution_clock::now();
289+
averageStart = high_resolution_clock::now();
286290
#endif
287291

288292
// Rendering
@@ -315,7 +319,7 @@ int run() {
315319

316320
window.swapBuffers();
317321

318-
#ifndef NDEBUG
322+
#ifdef FLOX_SHOW_DEBUG_INFO
319323
renderDurationAverage += delta(averageStart);
320324
#endif
321325

@@ -331,7 +335,7 @@ int run() {
331335
}
332336

333337
secondStart = high_resolution_clock::now();
334-
#ifndef NDEBUG
338+
#ifdef FLOX_SHOW_DEBUG_INFO
335339
std::cout << "Average framerate for last " << frameCount << " frames: " << fps << " | " << 1.0 / fps << 's' << std::endl;
336340

337341
const auto frameth = 1.0 / static_cast<double>(frameCount);

0 commit comments

Comments
 (0)