Skip to content

Commit

Permalink
Merge pull request #34 from bcahue/stable
Browse files Browse the repository at this point in the history
stable
  • Loading branch information
bcahue committed Feb 20, 2022
2 parents d14b542 + 063bdb5 commit b2d34bd
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 29 deletions.
2 changes: 1 addition & 1 deletion ci/win-buildgen.ps1
Expand Up @@ -3,7 +3,7 @@ Set-PSDebug -Trace 1
mkdir build | Out-Null
Set-Location build

& cmake .. -G "Visual Studio 16 2019" `
& cmake .. -G "Visual Studio 17 2022" `
-DBUILD_OR_FAIL=1 `
-DBUILD_CLIENT=1 -DBUILD_SERVER=1 `
-DBUILD_MASTER=1 -DBUILD_LAUNCHER=1
Expand Down
2 changes: 1 addition & 1 deletion ci/win-x32-buildgen.ps1
Expand Up @@ -4,6 +4,6 @@ mkdir "build-x32" | Out-Null
Set-Location "build-x32"

& cmake .. `
-G "Visual Studio 16 2019" -A Win32 -DBUILD_ODALAUNCH=0 `
-G "Visual Studio 17 2022" -A Win32 -DBUILD_ODALAUNCH=0 `

Set-Location ..
106 changes: 85 additions & 21 deletions client/src/v_video.cpp
Expand Up @@ -589,6 +589,7 @@ void V_MarkRect(int x, int y, int width, int height)
const int GRAPH_WIDTH = 140;
const int GRAPH_HEIGHT = 80;
const double GRAPH_BASELINE = 1000 / 60.0;
const double GRAPH_CAPPED_BASELINE = 1000 / 35.0;

struct frametimeGraph_t
{
Expand Down Expand Up @@ -623,8 +624,30 @@ struct frametimeGraph_t
newmax = data[i];
}

minimum = newmin;
maximum = newmax;
// Round to nearest power of two.
if (newmin <= 0.0)
{
minimum = 0.0;
}
else
{
double low = ::GRAPH_BASELINE;
while (low > newmin)
low /= 2;
minimum = low;
}

if (newmax >= 1000.0)
{
newmax = 1000.0;
}
else
{
double hi = ::GRAPH_BASELINE;
while (hi < newmax)
hi *= 2;
maximum = hi;
}
}

void push(const double val)
Expand Down Expand Up @@ -679,46 +702,71 @@ void V_DrawFPSWidget()

::g_GraphData.push(delta_time_ms);

v2int_t topleft(8, I_GetSurfaceHeight() / 2 + 16);
v2int_t topright(topleft.x + ::GRAPH_WIDTH, topleft.y);
v2int_t botleft(topleft.x, topleft.y + ::GRAPH_HEIGHT);
v2int_t botright(topleft.x + ::GRAPH_WIDTH, topleft.y + ::GRAPH_HEIGHT);
const rectInt_t graphBox =
M_RectFromDimensions(v2int_t(8, I_GetSurfaceHeight() / 2 + 16),
v2int_t(::GRAPH_WIDTH, ::GRAPH_HEIGHT));

// Data
for (size_t count = 1; count < ::GRAPH_WIDTH - 2; count++)
{
double start = ::g_GraphData.getTail(count - 1);
double end = ::g_GraphData.getTail(count);
const double start = ::g_GraphData.getTail(count - 1);
const double end = ::g_GraphData.getTail(count);

int startoff = ::g_GraphData.normalize(start) * (GRAPH_HEIGHT - 2);
int endoff = ::g_GraphData.normalize(end) * (GRAPH_HEIGHT - 2);
const int startoff = ::g_GraphData.normalize(start) * (::GRAPH_HEIGHT - 2);
const int endoff = ::g_GraphData.normalize(end) * (::GRAPH_HEIGHT - 2);

v2int_t startvec(botright.x - count, botright.y - startoff);
v2int_t endvec(botright.x - count - 1, botright.y - endoff);
const v2int_t startvec(graphBox.max.x - count, graphBox.max.y - startoff);
const v2int_t endvec(graphBox.max.x - count - 1, graphBox.max.y - endoff);

screen->Line(startvec, endvec, argb_t(255, 255, 255));
}

// 35fps baseline
const int baseY35 =
::g_GraphData.normalize(::GRAPH_CAPPED_BASELINE) * (::GRAPH_HEIGHT - 2);
const int offY35 = graphBox.max.y - baseY35;
if (offY35 > graphBox.min.y && offY35 < graphBox.max.y)
{
screen->Line(v2int_t(graphBox.min.x, offY35), v2int_t(graphBox.max.x, offY35),
argb_t(0x00, 0x00, 0xff));
}

// 60fps Baseline
const int baseY60 =
::g_GraphData.normalize(::GRAPH_BASELINE) * (::GRAPH_HEIGHT - 2);
const int offY60 = graphBox.max.y - baseY60;
if (offY60 > graphBox.min.y && offY60 < graphBox.max.y)
{
screen->Line(v2int_t(graphBox.min.x, offY60), v2int_t(graphBox.max.x, offY60),
argb_t(0x00, 0xff, 0x00));
}

// Box
screen->Line(topleft, topright, argb_t(255, 255, 255));
screen->Line(botleft, botright, argb_t(255, 255, 255));
screen->Line(topleft, botleft, argb_t(255, 255, 255));
screen->Line(topright, botright, argb_t(255, 255, 255));
screen->Box(graphBox, argb_t(0xcb, 0xcb, 0xcb));

// Box Shadow
screen->Line(v2int_t(graphBox.min.x + 1, graphBox.max.y + 1),
v2int_t(graphBox.max.x + 1, graphBox.max.y + 1),
argb_t(0x13, 0x13, 0x13));
screen->Line(v2int_t(graphBox.max.x + 1, graphBox.min.y + 1),
v2int_t(graphBox.max.x + 1, graphBox.max.y + 1),
argb_t(0x13, 0x13, 0x13));

// Min
StrFormat(buffer, "%4.1f", ::g_GraphData.minimum);
screen->PrintStr(botright.x, botright.y - 3, buffer.c_str());
screen->PrintStr(graphBox.max.x, graphBox.max.y - 3, buffer.c_str());

// Max
StrFormat(buffer, "%4.1f", ::g_GraphData.maximum);
screen->PrintStr(topright.x, topright.y - 3, buffer.c_str());
screen->PrintStr(graphBox.max.x, graphBox.min.y - 3, buffer.c_str());

// Actual
StrFormat(buffer, "%4.1f", delta_time_ms);
screen->PrintStr(topright.x, topright.y + (GRAPH_HEIGHT / 2) - 3, buffer.c_str());
screen->PrintStr(graphBox.max.x, graphBox.min.y + (::GRAPH_HEIGHT / 2) - 3,
buffer.c_str());

// Name
screen->PrintStr(topleft.x, topleft.y - 8, "Frametime (ms)");
screen->PrintStr(graphBox.min.x, graphBox.min.y - 8, "Frametime (ms)");

time_accum += delta_time;

Expand All @@ -735,7 +783,7 @@ void V_DrawFPSWidget()

// FPS counter
StrFormat(buffer, "FPS %5.1f", last_fps);
screen->PrintStr(botleft.x, botleft.y + 1, buffer.c_str());
screen->PrintStr(graphBox.min.x, graphBox.max.y + 1, buffer.c_str());
}
else if (vid_displayfps.asInt() == FPS_COUNTER)
{
Expand Down Expand Up @@ -1002,6 +1050,22 @@ void DCanvas::Line(const v2int_t src, const v2int_t dst, argb_t color) const
}
}

/**
* @brief Draw an empty box according to a rectangle.
*
* @param bounds Boundary of the rectangle, inclusive.
* @param color Color of the rectangle.
*/
void DCanvas::Box(const rectInt_t& bounds, const argb_t color) const
{
const v2int_t topRight(bounds.max.x, bounds.min.y);
const v2int_t botLeft(bounds.min.x, bounds.max.y);
Line(bounds.min, topRight, color);
Line(topRight, bounds.max, color);
Line(bounds.min, botLeft, color);
Line(botLeft, bounds.max, color);
}

EXTERN_CVAR (ui_dimamount)
EXTERN_CVAR (ui_dimcolor)

Expand Down
10 changes: 7 additions & 3 deletions common/c_cvars.cpp
Expand Up @@ -779,14 +779,18 @@ BEGIN_COMMAND (help)
}
END_COMMAND (help)

// [AM] Crash Odamex on purpose - with no survivors. Used for testing crash handlers.
BEGIN_COMMAND(errorout)
{
I_FatalError("errorout was run from the console");
I_Error("errorout was run from the console");
}
END_COMMAND(errorout)

// [AM] Crash Odamex on purpose - with no survivors. Used for testing crash handlers.
BEGIN_COMMAND(fatalout)
{
I_FatalError("fatalout was run from the console");
}
END_COMMAND(fatalout)

#if defined _WIN32

BEGIN_COMMAND(crashout)
Expand Down
10 changes: 9 additions & 1 deletion common/m_vectors.cpp
Expand Up @@ -681,6 +681,14 @@ void M_TranslateVec3 (v3double_t *vec, const v3double_t *origin, angle_t ang)
vec->y = ty;
}

rectInt_t M_RectFromDimensions(const v2int_t& origin, const v2int_t& dims)
{
rectInt_t rvo;
rvo.min = origin;
rvo.max = origin;
rvo.max.x += dims.x;
rvo.max.y += dims.y;
return rvo;
}

VERSION_CONTROL (m_vectors_cpp, "$Id$")

17 changes: 17 additions & 0 deletions common/m_vectors.h
Expand Up @@ -92,6 +92,21 @@ struct v3double_t
double x, y, z;
};

struct rectInt_t
{
rectInt_t() : min(0, 0), max(0, 0) { }

rectInt_t(const v2int_t min, const v2int_t max) : min(min), max(max) { }

rectInt_t(const int x1, const int y1, const int x2, const int y2)
: min(x1, y1), max(x2, y2)
{
}

rectInt_t(const rectInt_t& other) : min(other.min), max(other.max) { }

v2int_t min, max;
};

//
// M_SetVec3f
Expand Down Expand Up @@ -264,5 +279,7 @@ void M_RotatePointAroundVector(v3double_t *dest, const v3double_t *dir, const v3
void M_TranslateVec3f(v3float_t *vec, const v3float_t *origin, angle_t ang);
void M_TranslateVec3(v3double_t *vec, const v3double_t *origin, angle_t ang);

rectInt_t M_RectFromDimensions(const v2int_t& origin, const v2int_t& dims);

#endif //__M_VECTORS_H__

3 changes: 3 additions & 0 deletions common/v_video.h
Expand Up @@ -100,6 +100,9 @@ class DCanvas : DObject
// Draw a line with a specified color
void Line(const v2int_t src, const v2int_t dst, argb_t color) const;

// Draw an empty box with a specified border color
void Box(const rectInt_t& bounds, const argb_t color) const;

// Text drawing functions
// Output a line of text using the console font
void PrintStr(int x, int y, const char *s, int default_color = -1, bool use_color_codes = true) const;
Expand Down
4 changes: 2 additions & 2 deletions installer/windows/build_release.ps1
Expand Up @@ -26,7 +26,7 @@ function BuildX64 {
New-Item -Force -ItemType "directory" -Path "${PSScriptRoot}\BuildX64"
Set-Location -Path "${PSScriptRoot}\BuildX64"

cmake.exe -G "Visual Studio 16 2019" -A "x64" "${PSScriptRoot}\..\.." `
cmake.exe -G "Visual Studio 17 2022" -A "x64" "${PSScriptRoot}\..\.." `
-DBUILD_OR_FAIL=1 `
-DBUILD_CLIENT=1 -DBUILD_SERVER=1 `
-DBUILD_MASTER=1 -DBUILD_LAUNCHER=1
Expand All @@ -40,7 +40,7 @@ function BuildX86 {
New-Item -Force -ItemType "directory" -Path "${PSScriptRoot}\BuildX86"
Set-Location -Path "${PSScriptRoot}\BuildX86"

cmake.exe -G "Visual Studio 16 2019" -A "Win32" "${PSScriptRoot}\..\.." `
cmake.exe -G "Visual Studio 17 2022" -A "Win32" "${PSScriptRoot}\..\.." `
-DBUILD_OR_FAIL=1 `
-DBUILD_CLIENT=1 -DBUILD_SERVER=1 `
-DBUILD_MASTER=1 -DBUILD_LAUNCHER=1
Expand Down

0 comments on commit b2d34bd

Please sign in to comment.