target fps
This commit is contained in:
33
main.c
33
main.c
@ -26,6 +26,7 @@ typedef struct {
|
||||
Vector2 center;
|
||||
bool gaz;
|
||||
float nGaz;
|
||||
int targetFps;
|
||||
} Michelson;
|
||||
|
||||
Color WavelengthToColor(float lambda) {
|
||||
@ -445,13 +446,39 @@ void DrawControlPanel(Michelson *mic) {
|
||||
float p = (delta * 1000.0f) / refLambda;
|
||||
DrawText(TextFormat("Ordre p (sel) = %.2f", p), startX, startY + 65, 20, WHITE);
|
||||
|
||||
// Bas
|
||||
// FPS
|
||||
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));
|
||||
int fps = GetFPS();
|
||||
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(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};
|
||||
@ -522,14 +549,12 @@ void UpdateDrawFrame(void) {
|
||||
|
||||
|
||||
int main () {
|
||||
//SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
#if defined(PLATFORM_WEB)
|
||||
InitWindow(1920, 1080, "Interferometre de Michelson");
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
#else
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_MSAA_4X_HINT);
|
||||
InitWindow(1280, 720, "Interferometre de Michelson");
|
||||
SetWindowMinSize(640, 360);
|
||||
#endif
|
||||
|
||||
SetTargetFPS(0);
|
||||
|
||||
Reference in New Issue
Block a user