1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

on screen debug

This commit is contained in:
FunkyFr3sh 2018-06-26 14:06:02 +02:00
parent fa54189259
commit 7108f2af7a
4 changed files with 43 additions and 3 deletions

View File

@ -2,7 +2,7 @@
#define vxstr(a,b,c,d) str(a##.##b##.##c##.##d) #define vxstr(a,b,c,d) str(a##.##b##.##c##.##d)
#define str(s) #s #define str(s) #s
#define VERSION 1,1,7,1 #define VERSION 1,1,7,3
1 VERSIONINFO 1 VERSIONINFO
FILEVERSION VERSION FILEVERSION VERSION

View File

@ -418,13 +418,26 @@ DWORD WINAPI render_main(void)
#if _DEBUG #if _DEBUG
static DWORD tick_fps = 0; static DWORD tick_fps = 0;
static DWORD frame_count = 0; static DWORD frame_count = 0;
static char debugText[512] = { 0 };
static double frameTime = 0;
RECT debugrc = { 0, 0, ddraw->width, ddraw->height };
tick_start = timeGetTime(); tick_start = timeGetTime();
if (tick_start >= tick_fps) if (tick_start >= tick_fps)
{ {
printf("Frames: %lu - Elapsed: %lu ms\n", frame_count, (tick_start - tick_fps) + 1000); snprintf(
debugText, sizeof(debugText),
"FPS: %lu | Time: %2.2f ms",
frame_count, frameTime);
frame_count = 0; frame_count = 0;
tick_fps = tick_start + 1000; tick_fps = tick_start + 1000;
CounterStart();
} }
if (ddraw->primary && ddraw->primary->palette)
DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP);
frame_count++; frame_count++;
#endif #endif
@ -595,6 +608,10 @@ DWORD WINAPI render_main(void)
SwapBuffers(ddraw->render.hDC); SwapBuffers(ddraw->render.hDC);
#if _DEBUG
if (frame_count == 1) frameTime = CounterStop();
#endif
if (maxfps > 0) if (maxfps > 0)
{ {
tick_end = timeGetTime(); tick_end = timeGetTime();

View File

@ -87,13 +87,26 @@ DWORD WINAPI render_soft_main(void)
#if _DEBUG #if _DEBUG
static DWORD tick_fps = 0; static DWORD tick_fps = 0;
static DWORD frame_count = 0; static DWORD frame_count = 0;
static char debugText[512] = { 0 };
static double frameTime = 0;
RECT debugrc = { 0, 0, ddraw->width, ddraw->height };
tick_start = timeGetTime(); tick_start = timeGetTime();
if (tick_start >= tick_fps) if (tick_start >= tick_fps)
{ {
printf("Frames: %lu - Elapsed: %lu ms\n", frame_count, (tick_start - tick_fps) + 1000); snprintf(
debugText, sizeof(debugText),
"FPS: %lu | Time: %2.2f ms",
frame_count, frameTime);
frame_count = 0; frame_count = 0;
tick_fps = tick_start + 1000; tick_fps = tick_start + 1000;
CounterStart();
} }
if (ddraw->primary && ddraw->primary->palette)
DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP);
frame_count++; frame_count++;
#endif #endif
@ -164,6 +177,10 @@ DWORD WINAPI render_soft_main(void)
LeaveCriticalSection(&ddraw->cs); LeaveCriticalSection(&ddraw->cs);
#if _DEBUG
if (frame_count == 1) frameTime = CounterStop();
#endif
if(maxfps > 0) if(maxfps > 0)
{ {
tick_end = timeGetTime(); tick_end = timeGetTime();

View File

@ -508,6 +508,12 @@ HRESULT __stdcall ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC lpD
Surface->bmi->bmiColors[i].rgbReserved = 0; Surface->bmi->bmiColors[i].rgbReserved = 0;
} }
#if _DEBUG
Surface->bmi->bmiColors[255].rgbRed = 250;
Surface->bmi->bmiColors[255].rgbGreen = 250;
Surface->bmi->bmiColors[255].rgbBlue = 250;
#endif
Surface->lXPitch = Surface->bpp / 8; Surface->lXPitch = Surface->bpp / 8;
Surface->lPitch = Surface->width * Surface->lXPitch; Surface->lPitch = Surface->width * Surface->lXPitch;