Skip to content

Commit

Permalink
Use different waitloop on debug/release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
celerizer committed Jan 15, 2024
1 parent 27d67a4 commit 32ee848
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions QRetro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ bool QRetro::event(QEvent *ev)
painter.fillRect(0, 0, size().width(), size().height(), Qt::black);
painter.drawImage(m_Rect, m_Image);

#if QRETRO_DRAW_DEBUG
#if QRETRO_DEBUG
painter.setPen(Qt::red);
painter.drawText(16, size().height() - 16, "Software");
#endif
Expand Down Expand Up @@ -184,7 +184,7 @@ bool QRetro::event(QEvent *ev)
painter.fillRect(0, 0, size().width(), size().height(), Qt::black);
painter.drawImage(m_Rect, m_Image);

#if QRETRO_DRAW_DEBUG
#if QRETRO_DEBUG
if (m_OpenGlFbo)
{
painter.setPen(Qt::yellow);
Expand Down Expand Up @@ -582,9 +582,17 @@ void QRetro::timing()
if (m_FastForwarding && m_FastForwardRatio <= 1.0f)
continue;

/* Wake up right before next frames is needed */
this_thread::sleep_until(next - milliseconds(2));

/* Waitloop until exact timing */
while (steady_clock::now() < next);

#if QRETRO_DEBUG
next += nanoseconds(time);
#else
next = steady_clock::now() + nanoseconds(time);
#endif
}
}

Expand Down
4 changes: 2 additions & 2 deletions QRetro.pri
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ QT += core gui multimedia
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG(debug, debug|release) {
DEFINES += QRETRO_DRAW_DEBUG=1
DEFINES += QRETRO_DEBUG=1
} else {
DEFINES += QRETRO_DRAW_DEBUG=0
DEFINES += QRETRO_DEBUG=0
}

!QRETRO_CONFIG_NO_CAMERA {
Expand Down

0 comments on commit 32ee848

Please sign in to comment.