Framerate test (Press 1)
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m42s

This commit is contained in:
2024-08-22 19:27:31 -04:00
parent 1d8823b046
commit 6650af4fc4
3 changed files with 33 additions and 3 deletions

View File

@@ -206,7 +206,6 @@ namespace JGL {
// TODO: Implement the following:
void FillTexturedTriangle();
void FillTexturedPolygon();
void DrawCubicBezierCurve(const Color4& color,
@@ -215,9 +214,14 @@ namespace JGL {
int subdivisions = 10,
float thickness = 1);
/// Draws a series of lines where the last line will *always* connect to the beginning of the first.
/// Draws a series of points where the last point always connects to the first point.
void OutlinePolygon (const Color4& color, const std::vector<Vector2>& points, float thickness = 1);
void FillPolygon (const Color4& color, std::vector<Vector2> points);
/// Draws a series of points where the last point always connects to the first point and fills it in.
///TODO these ones are going to be extremely annoying.
void FillPolygon (const Color4& color, const std::vector<Vector2>& points);
void FillTexturedPolygon();
void OutlineRoundedRect(const Color4& color, const Vector2& pos, const Vector2& size, float radius = 5, float thickness = 1);
}

View File

@@ -2,6 +2,7 @@
#include <JGL/JGL.h>
#include <rewindow/types/window.h>
#include <Colors.hpp>
#include <chrono>
#include <J3ML/LinearAlgebra/Vector2.hpp>
#include <JGL/Font.h>
#include <jlog/jlog.hpp>
@@ -140,8 +141,15 @@ public:
Vector3 textAngle = {0,0,0};
float fov = 90;
bool fov_increasing = true;
unsigned long long frames = 0;
bool framerate_measurement = false;
std::chrono::system_clock::time_point start;
float elapsed = 0.0f;
void display() {
if (framerate_measurement)
start = std::chrono::high_resolution_clock::now();
JGL::Update(getSize());
if (fov_increasing)
fov += 0.25;
@@ -193,6 +201,7 @@ public:
J2D::DrawString(Colors::White, "Position: " + std::to_string(camera->position.x) + " " + std::to_string(camera->position.y) + " " + std::to_string(camera->position.z), 0, 16, 1,16, Jupiteroid);
J2D::DrawString(Colors::White, "ViewAngle: " + std::to_string(camera->angle.x) + " " + std::to_string(camera->angle.y) + " " + std::to_string(camera->angle.z), 0, 33, 1,16, Jupiteroid);
J2D::OutlinePolygon(Colors::White, {{200, 400}, {220, 420}, {220, 430}, {230, 410}, {200, 400}});
//J2D::FillPolygon(Colors::White, {{200, 400}, {220, 420}, {220, 430}, {230, 410}, {200, 400}});
J2D::DrawCubicBezierCurve(Colors::Blues::CornflowerBlue,
a.position,
b.position,
@@ -205,6 +214,22 @@ public:
c.Draw();
d.Draw();
J2D::End();
if (framerate_measurement) {
frames++;
std::chrono::system_clock::time_point stop = std::chrono::high_resolution_clock::now();
std::chrono::duration<float> frame_time = stop - start;
elapsed += frame_time.count();
if (elapsed >= 1)
std::cout << "Framerate: " << frames << std::endl,
frames = 0,
elapsed = 0,
framerate_measurement = false,
setVsyncEnabled(true);
} else if (isKeyDown(Keys::One))
framerate_measurement = true,
frames = 0,
setVsyncEnabled(false);
}
void OnRefresh(float elapsed) override {

View File

@@ -436,6 +436,7 @@ namespace JGL {
glDrawArrays(GL_LINE_LOOP, 0, points.size());
glColor4f(baseColor[0], baseColor[1], baseColor[2], baseColor[3]);
}
void J2D::DrawPoint(const Color4& color, const Vector2& coordinates, float radius) {
if (!inJ2D)
ERROR("Drawing J2D element before J2D begin.");