target fps

This commit is contained in:
2025-12-29 15:00:48 +01:00
parent 99fbef5c4b
commit 40213d7e69

33
main.c
View File

@ -26,6 +26,7 @@ typedef struct {
Vector2 center; Vector2 center;
bool gaz; bool gaz;
float nGaz; float nGaz;
int targetFps;
} Michelson; } Michelson;
Color WavelengthToColor(float lambda) { Color WavelengthToColor(float lambda) {
@ -445,13 +446,39 @@ void DrawControlPanel(Michelson *mic) {
float p = (delta * 1000.0f) / refLambda; float p = (delta * 1000.0f) / refLambda;
DrawText(TextFormat("Ordre p (sel) = %.2f", p), startX, startY + 65, 20, WHITE); DrawText(TextFormat("Ordre p (sel) = %.2f", p), startX, startY + 65, 20, WHITE);
// Bas // FPS
int bottomY = GetScreenHeight() - 40; int bottomY = GetScreenHeight() - 40;
int perfStartY = bottomY - 80;
DrawLine(startX, perfStartY - 10, startX + contentWidth, perfStartY - 10, GRAY);
DrawText("PERFORMANCES (Cible FPS)", startX, perfStartY, 20, GRAY);
int fpsValues[] = {0, 30, 60, 120, 144};
const char* fpsTexts[] = {"MAX", "30", "60", "120", "144"};
int fpsCount = 5;
int fpsSpacing = 5;
int fpsBtnW = (contentWidth - (fpsSpacing * (fpsCount - 1))) / fpsCount;
for (int i = 0; i < fpsCount; i++) {
Rectangle fpsRect = {startX + i * (fpsBtnW + fpsSpacing), perfStartY + 30, fpsBtnW, 25};
bool isCurrent = (mic->targetFps == i);
if (GuiButton(fpsRect, fpsTexts[i])) {
mic->targetFps = i;
SetTargetFPS(fpsValues[i]);
}
if (isCurrent) {
DrawRectangleLinesEx(fpsRect, 2, COLOR_ACCENT);
DrawRectangle(fpsRect.x + 2, fpsRect.y + 2, fpsRect.width-4, fpsRect.height-4, Fade(COLOR_ACCENT, 0.2f));
}
}
// Bas
DrawLine(0, bottomY, UI_WIDTH, bottomY, Fade(WHITE, 0.1f)); DrawLine(0, bottomY, UI_WIDTH, bottomY, Fade(WHITE, 0.1f));
int fps = GetFPS(); int fps = GetFPS();
Color fpsColor = (fps >= 100) ? COLOR_ACCENT : (fps >= 60 ? GREEN : (fps >= 30 ? ORANGE : RED)); Color fpsColor = (fps >= 100) ? COLOR_ACCENT : (fps >= 60 ? GREEN : (fps >= 30 ? ORANGE : RED));
int currentFpsVal = fpsValues[mic->targetFps];
DrawText("STATUT:", startX, bottomY + 12, 20, COLOR_TEXT_DIM); DrawText("STATUT:", startX, bottomY + 12, 20, COLOR_TEXT_DIM);
DrawText(TextFormat("%i FPS", fps), startX + 100, bottomY + 12, 20, fpsColor); DrawText(TextFormat("%i FPS (%s)", fps, (currentFpsVal == 0 ? "Max" : TextFormat("%i", currentFpsVal))), startX + 100, bottomY + 12, 20, fpsColor);
} }
Michelson mic = {0}; Michelson mic = {0};
@ -522,14 +549,12 @@ void UpdateDrawFrame(void) {
int main () { int main () {
//SetConfigFlags(FLAG_MSAA_4X_HINT);
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
InitWindow(1920, 1080, "Interferometre de Michelson"); InitWindow(1920, 1080, "Interferometre de Michelson");
SetConfigFlags(FLAG_MSAA_4X_HINT); SetConfigFlags(FLAG_MSAA_4X_HINT);
#else #else
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_MSAA_4X_HINT); SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_MSAA_4X_HINT);
InitWindow(1280, 720, "Interferometre de Michelson"); InitWindow(1280, 720, "Interferometre de Michelson");
SetWindowMinSize(640, 360);
#endif #endif
SetTargetFPS(0); SetTargetFPS(0);