agrandir la figure d'interf
This commit is contained in:
25
main.c
25
main.c
@ -99,16 +99,25 @@ void DrawInterferenceViewCPU(Michelson *mic, Rectangle rec) {
|
|||||||
DrawLine(cx, cy - 10, cx, cy + 10, Fade(WHITE, 0.5f));
|
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);
|
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);
|
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
|
// Shader glsl
|
||||||
float centerX = rec.x + rec.width / 2.0f;
|
float centerX = rec.x + rec.width / 2.0f;
|
||||||
float centerY = rec.y + rec.height / 2.0f;
|
float centerY = rec.y + rec.height / 2.0f;
|
||||||
float center[2] = { centerX, centerY };
|
float center[2] = { centerX, centerY };
|
||||||
float scrHeight = (float)GetScreenHeight();
|
float scrHeight = (float)GetScreenHeight();
|
||||||
|
float zoom = *isFullscreen ? 0.7 : 1;
|
||||||
|
|
||||||
//
|
//
|
||||||
SetShaderValue(shader, GetShaderLocation(shader, "center"), center, SHADER_UNIFORM_VEC2);
|
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, "d2"), &mic->d2, SHADER_UNIFORM_FLOAT);
|
||||||
SetShaderValue(shader, GetShaderLocation(shader, "lambda"), &mic->lambda, 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, "angleM1"), &mic->angleM1, SHADER_UNIFORM_FLOAT);
|
||||||
|
SetShaderValue(shader, GetShaderLocation(shader, "zoom"), &zoom, SHADER_UNIFORM_FLOAT);
|
||||||
|
|
||||||
// GPU
|
// GPU
|
||||||
BeginShaderMode(shader);
|
BeginShaderMode(shader);
|
||||||
@ -294,7 +304,7 @@ void DrawControlPanel(Michelson *mic) {
|
|||||||
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));
|
||||||
DrawText("STATUT:", startX, bottomY + 12, 20, COLOR_TEXT_DIM);
|
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 () {
|
int main () {
|
||||||
@ -311,10 +321,17 @@ int main () {
|
|||||||
mic.lambda = 550.0f;
|
mic.lambda = 550.0f;
|
||||||
mic.angleM1 = 0.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};
|
//Rectangle screenViewBounds = {400, 0, 1080, 1080};
|
||||||
|
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) {
|
||||||
|
if (IsKeyPressed(KEY_F)) {
|
||||||
|
isFullscreen = !isFullscreen;
|
||||||
|
}
|
||||||
|
Rectangle currentViewBounds = isFullscreen ? fullScreenBounds : normalBounds;
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(COLOR_BG);
|
ClearBackground(COLOR_BG);
|
||||||
// Grille fond
|
// Grille fond
|
||||||
@ -323,7 +340,7 @@ int main () {
|
|||||||
|
|
||||||
DrawMichelsonSchema(&mic);
|
DrawMichelsonSchema(&mic);
|
||||||
DrawControlPanel(&mic);
|
DrawControlPanel(&mic);
|
||||||
DrawInterferenceViewGPU(&mic, screenViewBounds, shader);
|
DrawInterferenceViewGPU(&mic, currentViewBounds, shader, &isFullscreen);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
|
|||||||
@ -13,6 +13,7 @@ uniform float d1;
|
|||||||
uniform float d2;
|
uniform float d2;
|
||||||
uniform float lambda;
|
uniform float lambda;
|
||||||
uniform float angleM1;
|
uniform float angleM1;
|
||||||
|
uniform float zoom;
|
||||||
|
|
||||||
const float PI = 3.14159265359;
|
const float PI = 3.14159265359;
|
||||||
|
|
||||||
@ -40,8 +41,8 @@ void main() {
|
|||||||
// Diff de marche du à l'axe (2 * e) + micro -> nano
|
// Diff de marche du à l'axe (2 * e) + micro -> nano
|
||||||
float deltaLnm = 2.0 * (d1 - d2) * 1000.0;
|
float deltaLnm = 2.0 * (d1 - d2) * 1000.0;
|
||||||
|
|
||||||
float relX = (pixelX - center.x);
|
float relX = (pixelX - center.x) * zoom;
|
||||||
float relY = (pixelY - center.y);
|
float relY = (pixelY - center.y) * zoom;
|
||||||
|
|
||||||
vec3 baseColorVec = WavelengthToRGB(lambda);
|
vec3 baseColorVec = WavelengthToRGB(lambda);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user