diff --git a/main.c b/main.c index 6012017..fa3ba32 100644 --- a/main.c +++ b/main.c @@ -99,16 +99,25 @@ void DrawInterferenceViewCPU(Michelson *mic, Rectangle rec) { DrawLine(cx, cy - 10, cx, cy + 10, Fade(WHITE, 0.5f)); } -void DrawInterferenceViewGPU(Michelson *mic, Rectangle rec, Shader shader) { +void DrawInterferenceViewGPU(Michelson *mic, Rectangle rec, Shader shader, bool *isFullscreen) { DrawRectangleRec((Rectangle){rec.x - 4, rec.y - 30, rec.width + 8, rec.height + 34}, COLOR_PANEL); DrawText("ECRAN", rec.x, rec.y - 26, 20, COLOR_TEXT_DIM); + const char* btnText = *isFullscreen ? "PETIT" : "GRAND"; + if (GuiButton((Rectangle){rec.x + rec.width - 80, rec.y - 28, 80, 24}, btnText)) { + *isFullscreen = !(*isFullscreen); + } + if (CheckCollisionPointRec(GetMousePosition(), (Rectangle){rec.x + rec.width - 80, rec.y - 28, 80, 24})) { + DrawText("(Touche F)", rec.x + rec.width - 160, rec.y - 22, 10, GRAY); + } + // Shader glsl float centerX = rec.x + rec.width / 2.0f; float centerY = rec.y + rec.height / 2.0f; float center[2] = { centerX, centerY }; float scrHeight = (float)GetScreenHeight(); + float zoom = *isFullscreen ? 0.7 : 1; // SetShaderValue(shader, GetShaderLocation(shader, "center"), center, SHADER_UNIFORM_VEC2); @@ -118,6 +127,7 @@ void DrawInterferenceViewGPU(Michelson *mic, Rectangle rec, Shader shader) { SetShaderValue(shader, GetShaderLocation(shader, "d2"), &mic->d2, SHADER_UNIFORM_FLOAT); SetShaderValue(shader, GetShaderLocation(shader, "lambda"), &mic->lambda, SHADER_UNIFORM_FLOAT); SetShaderValue(shader, GetShaderLocation(shader, "angleM1"), &mic->angleM1, SHADER_UNIFORM_FLOAT); + SetShaderValue(shader, GetShaderLocation(shader, "zoom"), &zoom, SHADER_UNIFORM_FLOAT); // GPU BeginShaderMode(shader); @@ -294,7 +304,7 @@ void DrawControlPanel(Michelson *mic) { int fps = GetFPS(); Color fpsColor = (fps >= 100) ? COLOR_ACCENT : (fps >= 60 ? GREEN : (fps >= 30 ? ORANGE : RED)); DrawText("STATUT:", startX, bottomY + 12, 20, COLOR_TEXT_DIM); - DrawText(TextFormat("GPU MODE | %i FPS", fps), startX + 100, bottomY + 12, 20, fpsColor); + DrawText(TextFormat("%i FPS", fps), startX + 100, bottomY + 12, 20, fpsColor); } int main () { @@ -311,10 +321,17 @@ int main () { mic.lambda = 550.0f; mic.angleM1 = 0.0f; - Rectangle screenViewBounds = {1920 - 530, 50, 500, 500}; + bool isFullscreen = false; + + Rectangle normalBounds = {1920 - 530, 50, 500, 500}; + Rectangle fullScreenBounds = {UI_WIDTH + 10, 40, 1920 - UI_WIDTH - 20, 1030}; //Rectangle screenViewBounds = {400, 0, 1080, 1080}; while (!WindowShouldClose()) { + if (IsKeyPressed(KEY_F)) { + isFullscreen = !isFullscreen; + } + Rectangle currentViewBounds = isFullscreen ? fullScreenBounds : normalBounds; BeginDrawing(); ClearBackground(COLOR_BG); // Grille fond @@ -323,7 +340,7 @@ int main () { DrawMichelsonSchema(&mic); DrawControlPanel(&mic); - DrawInterferenceViewGPU(&mic, screenViewBounds, shader); + DrawInterferenceViewGPU(&mic, currentViewBounds, shader, &isFullscreen); EndDrawing(); } CloseWindow(); diff --git a/michelson b/michelson index a43bda8..537eb3b 100755 Binary files a/michelson and b/michelson differ diff --git a/michelson.fs b/michelson.fs index 3d8cca1..e10b4e6 100644 --- a/michelson.fs +++ b/michelson.fs @@ -13,6 +13,7 @@ uniform float d1; uniform float d2; uniform float lambda; uniform float angleM1; +uniform float zoom; const float PI = 3.14159265359; @@ -40,8 +41,8 @@ void main() { // Diff de marche du à l'axe (2 * e) + micro -> nano float deltaLnm = 2.0 * (d1 - d2) * 1000.0; - float relX = (pixelX - center.x); - float relY = (pixelY - center.y); + float relX = (pixelX - center.x) * zoom; + float relY = (pixelY - center.y) * zoom; vec3 baseColorVec = WavelengthToRGB(lambda);