mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
remove duplicate debug code
This commit is contained in:
parent
fa6f9e197e
commit
ebae1add37
@ -6,6 +6,11 @@
|
|||||||
void CounterStart();
|
void CounterStart();
|
||||||
double CounterStop();
|
double CounterStop();
|
||||||
void DebugPrint(const char *format, ...);
|
void DebugPrint(const char *format, ...);
|
||||||
|
void DrawFrameInfoStart();
|
||||||
|
void DrawFrameInfoEnd();
|
||||||
|
|
||||||
|
extern double DebugFrameTime;
|
||||||
|
extern DWORD DebugFrameCount;
|
||||||
|
|
||||||
//#define _DEBUG 1
|
//#define _DEBUG 1
|
||||||
|
|
||||||
|
41
src/debug.c
41
src/debug.c
@ -1,7 +1,11 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "main.h"
|
||||||
|
#include "surface.h"
|
||||||
|
|
||||||
|
double DebugFrameTime = 0;
|
||||||
|
DWORD DebugFrameCount = 0;
|
||||||
|
|
||||||
static LONGLONG CounterStartTime = 0;
|
static LONGLONG CounterStartTime = 0;
|
||||||
static double CounterFreq = 0.0;
|
static double CounterFreq = 0.0;
|
||||||
@ -30,3 +34,38 @@ void DebugPrint(const char *format, ...)
|
|||||||
_vsnprintf(buffer, sizeof(buffer), format, args);
|
_vsnprintf(buffer, sizeof(buffer), format, args);
|
||||||
OutputDebugStringA(buffer);
|
OutputDebugStringA(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawFrameInfoStart()
|
||||||
|
{
|
||||||
|
static DWORD tick_fps = 0;
|
||||||
|
static char debugText[512] = { 0 };
|
||||||
|
|
||||||
|
RECT debugrc = { 0, 0, ddraw->width, ddraw->height };
|
||||||
|
|
||||||
|
if (ddraw->primary && ddraw->primary->palette)
|
||||||
|
DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP);
|
||||||
|
|
||||||
|
DWORD tick_start = timeGetTime();
|
||||||
|
if (tick_start >= tick_fps)
|
||||||
|
{
|
||||||
|
snprintf(
|
||||||
|
debugText,
|
||||||
|
sizeof(debugText),
|
||||||
|
"FPS: %lu | Time: %2.2f ms ",
|
||||||
|
DebugFrameCount,
|
||||||
|
DebugFrameTime);
|
||||||
|
|
||||||
|
DebugFrameCount = 0;
|
||||||
|
tick_fps = tick_start + 1000;
|
||||||
|
|
||||||
|
CounterStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugFrameCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFrameInfoEnd()
|
||||||
|
{
|
||||||
|
if (DebugFrameCount == 1)
|
||||||
|
DebugFrameTime = CounterStop();
|
||||||
|
}
|
||||||
|
28
src/render.c
28
src/render.c
@ -550,31 +550,7 @@ static void Render()
|
|||||||
while (UseOpenGL && ddraw->render.run && WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED)
|
while (UseOpenGL && ddraw->render.run && WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED)
|
||||||
{
|
{
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
static DWORD tick_fps = 0;
|
DrawFrameInfoStart();
|
||||||
static DWORD frame_count = 0;
|
|
||||||
static char debugText[512] = { 0 };
|
|
||||||
static double frameTime = 0;
|
|
||||||
RECT debugrc = { 0, 0, ddraw->width, ddraw->height };
|
|
||||||
|
|
||||||
if (ddraw->primary && ddraw->primary->palette)
|
|
||||||
DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP);
|
|
||||||
|
|
||||||
tick_start = timeGetTime();
|
|
||||||
if (tick_start >= tick_fps)
|
|
||||||
{
|
|
||||||
snprintf(
|
|
||||||
debugText,
|
|
||||||
sizeof(debugText),
|
|
||||||
"FPS: %lu | Time: %2.2f ms ",
|
|
||||||
frame_count,
|
|
||||||
frameTime);
|
|
||||||
|
|
||||||
frame_count = 0;
|
|
||||||
tick_fps = tick_start + 1000;
|
|
||||||
|
|
||||||
CounterStart();
|
|
||||||
}
|
|
||||||
frame_count++;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ScaleW = (float)ddraw->width / SurfaceTexWidth;
|
ScaleW = (float)ddraw->width / SurfaceTexWidth;
|
||||||
@ -804,7 +780,7 @@ static void Render()
|
|||||||
glFinish();
|
glFinish();
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
if (frame_count == 1) frameTime = CounterStop();
|
DrawFrameInfoEnd();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (MaxFPS > 0)
|
if (MaxFPS > 0)
|
||||||
|
@ -40,7 +40,7 @@ static BOOL CreateDirect3D();
|
|||||||
static BOOL CreateResources();
|
static BOOL CreateResources();
|
||||||
static void SetStates();
|
static void SetStates();
|
||||||
static void UpdateVertices(BOOL inCutscene);
|
static void UpdateVertices(BOOL inCutscene);
|
||||||
static void Reset();
|
static BOOL Reset();
|
||||||
static void SetMaxFPS(int baseMaxFPS);
|
static void SetMaxFPS(int baseMaxFPS);
|
||||||
static void Render();
|
static void Render();
|
||||||
static void ReleaseDirect3D();
|
static void ReleaseDirect3D();
|
||||||
@ -199,12 +199,15 @@ static void UpdateVertices(BOOL inCutscene)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Reset()
|
static BOOL Reset()
|
||||||
{
|
{
|
||||||
if (SUCCEEDED(D3ddev->lpVtbl->Reset(D3ddev, &D3dpp)))
|
if (SUCCEEDED(D3ddev->lpVtbl->Reset(D3ddev, &D3dpp)))
|
||||||
{
|
{
|
||||||
SetStates();
|
SetStates();
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetMaxFPS(int baseMaxFPS)
|
static void SetMaxFPS(int baseMaxFPS)
|
||||||
@ -232,31 +235,7 @@ static void Render()
|
|||||||
while (ddraw->render.run && WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED)
|
while (ddraw->render.run && WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED)
|
||||||
{
|
{
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
static DWORD tick_fps = 0;
|
DrawFrameInfoStart();
|
||||||
static DWORD frame_count = 0;
|
|
||||||
static char debugText[512] = { 0 };
|
|
||||||
static double frameTime = 0;
|
|
||||||
RECT debugrc = { 0, 0, ddraw->width, ddraw->height };
|
|
||||||
|
|
||||||
if (ddraw->primary && ddraw->primary->palette)
|
|
||||||
DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP);
|
|
||||||
|
|
||||||
tick_start = timeGetTime();
|
|
||||||
if (tick_start >= tick_fps)
|
|
||||||
{
|
|
||||||
snprintf(
|
|
||||||
debugText,
|
|
||||||
sizeof(debugText),
|
|
||||||
"FPS: %lu | Time: %2.2f ms ",
|
|
||||||
frame_count,
|
|
||||||
frameTime);
|
|
||||||
|
|
||||||
frame_count = 0;
|
|
||||||
tick_fps = tick_start + 1000;
|
|
||||||
|
|
||||||
CounterStart();
|
|
||||||
}
|
|
||||||
frame_count++;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (MaxFPS > 0)
|
if (MaxFPS > 0)
|
||||||
@ -332,7 +311,7 @@ static void Render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
if (frame_count == 1) frameTime = CounterStop();
|
DrawFrameInfoEnd();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (MaxFPS > 0)
|
if (MaxFPS > 0)
|
||||||
|
@ -87,29 +87,7 @@ DWORD WINAPI render_soft_main(void)
|
|||||||
while (ddraw->render.run && WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED)
|
while (ddraw->render.run && WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED)
|
||||||
{
|
{
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
static DWORD tick_fps = 0;
|
DrawFrameInfoStart();
|
||||||
static DWORD frame_count = 0;
|
|
||||||
static char debugText[512] = { 0 };
|
|
||||||
static double frameTime = 0;
|
|
||||||
RECT debugrc = { 0, 0, ddraw->width, ddraw->height };
|
|
||||||
|
|
||||||
if (ddraw->primary && ddraw->primary->palette)
|
|
||||||
DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP);
|
|
||||||
|
|
||||||
tick_start = timeGetTime();
|
|
||||||
if (tick_start >= tick_fps)
|
|
||||||
{
|
|
||||||
snprintf(
|
|
||||||
debugText, sizeof(debugText),
|
|
||||||
"FPS: %lu | Time: %2.2f ms ",
|
|
||||||
frame_count, frameTime);
|
|
||||||
|
|
||||||
frame_count = 0;
|
|
||||||
tick_fps = tick_start + 1000;
|
|
||||||
|
|
||||||
CounterStart();
|
|
||||||
}
|
|
||||||
frame_count++;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(maxfps > 0)
|
if(maxfps > 0)
|
||||||
@ -192,7 +170,7 @@ DWORD WINAPI render_soft_main(void)
|
|||||||
LeaveCriticalSection(&ddraw->cs);
|
LeaveCriticalSection(&ddraw->cs);
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
if (frame_count == 1) frameTime = CounterStop();
|
DrawFrameInfoEnd();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(maxfps > 0)
|
if(maxfps > 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user