auto resize desktop
This commit is contained in:
91
main.c
91
main.c
@ -74,7 +74,8 @@ void DrawInterferenceViewGPU(Michelson *mic, Rectangle rec, Shader shader, bool
|
|||||||
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 scrHeight = 1080.0f;
|
||||||
float zoom = *isFullscreen ? 0.7 : 1;
|
float zoom = *isFullscreen ? 0.7 : 1;
|
||||||
|
|
||||||
float addedOpticalPathOneWay = 0.0f;
|
float addedOpticalPathOneWay = 0.0f;
|
||||||
@ -458,41 +459,80 @@ Shader shader;
|
|||||||
bool isFullscreen = false;
|
bool isFullscreen = false;
|
||||||
Rectangle normalBounds = {0};
|
Rectangle normalBounds = {0};
|
||||||
Rectangle fullScreenBounds = {0};
|
Rectangle fullScreenBounds = {0};
|
||||||
|
#if !defined(PLATFORM_WEB)
|
||||||
|
RenderTexture2D target;
|
||||||
|
#endif
|
||||||
|
|
||||||
void UpdateDrawFrame(void) {
|
void UpdateDrawFrame(void) {
|
||||||
if (IsKeyPressed(KEY_F)) {
|
if (IsKeyPressed(KEY_F)) {
|
||||||
isFullscreen = !isFullscreen;
|
isFullscreen = !isFullscreen;
|
||||||
}
|
}
|
||||||
Rectangle currentViewBounds = isFullscreen ? fullScreenBounds : normalBounds;
|
|
||||||
BeginDrawing();
|
|
||||||
ClearBackground(COLOR_BG);
|
|
||||||
float gridThick = 1.1f;
|
|
||||||
float gridAlpha = 0.03f;
|
|
||||||
// Grille fond
|
|
||||||
for(int i = UI_WIDTH; i < 1920; i += 100) DrawLine(i, 0, i, 1080, Fade(WHITE, 0.05f));
|
|
||||||
for(int i = 0; i < 1080; i += 100) DrawLine(UI_WIDTH, i, 1920, i, Fade(WHITE, 0.05f));
|
|
||||||
for(int i = UI_WIDTH; i < 1920; i += 100) {
|
|
||||||
DrawLineEx((Vector2){i, 0}, (Vector2){i, 1080}, gridThick, Fade(WHITE, gridAlpha));
|
|
||||||
}
|
|
||||||
for(int i = 0; i < 1080; i += 100) {
|
|
||||||
DrawLineEx((Vector2){UI_WIDTH, i}, (Vector2){1920, i}, gridThick, Fade(WHITE, gridAlpha));
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawMichelsonSchema(&mic);
|
Rectangle currentViewBounds = isFullscreen ? fullScreenBounds : normalBounds;
|
||||||
DrawControlPanel(&mic);
|
#if defined(PLATFORM_WEB)
|
||||||
DrawInterferenceViewGPU(&mic, currentViewBounds, shader, &isFullscreen);
|
BeginDrawing();
|
||||||
EndDrawing();
|
ClearBackground(COLOR_BG);
|
||||||
|
float gridThick = 1.1f;
|
||||||
|
float gridAlpha = 0.03f;
|
||||||
|
// Grille fond
|
||||||
|
for(int i = UI_WIDTH; i < 1920; i += 100) {
|
||||||
|
DrawLineEx((Vector2){i, 0}, (Vector2){i, 1080}, gridThick, Fade(WHITE, gridAlpha));
|
||||||
|
}
|
||||||
|
for(int i = 0; i < 1080; i += 100) {
|
||||||
|
DrawLineEx((Vector2){UI_WIDTH, i}, (Vector2){1920, i}, gridThick, Fade(WHITE, gridAlpha));
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawMichelsonSchema(&mic);
|
||||||
|
DrawControlPanel(&mic);
|
||||||
|
DrawInterferenceViewGPU(&mic, currentViewBounds, shader, &isFullscreen);
|
||||||
|
EndDrawing();
|
||||||
|
#else
|
||||||
|
float scale = fminf((float)GetScreenWidth() / 1920, (float)GetScreenHeight() / 1080);
|
||||||
|
float newWidth = 1920 * scale;
|
||||||
|
float newHeight = 1080 * scale;
|
||||||
|
float offsetX = (GetScreenWidth() - newWidth) * 0.5f;
|
||||||
|
float offsetY = (GetScreenHeight() - newHeight) * 0.5f;
|
||||||
|
SetMouseOffset(-offsetX, -offsetY);
|
||||||
|
SetMouseScale(1.0f / scale, 1.0f / scale);
|
||||||
|
BeginTextureMode(target);
|
||||||
|
ClearBackground(COLOR_BG);
|
||||||
|
float gridThick = 1.1f;
|
||||||
|
float gridAlpha = 0.03f;
|
||||||
|
// Grille fond
|
||||||
|
//for(int i = UI_WIDTH; i < 1920; i += 100) DrawLine(i, 0, i, 1080, Fade(WHITE, 0.05f));
|
||||||
|
//for(int i = 0; i < 1080; i += 100) DrawLine(UI_WIDTH, i, 1920, i, Fade(WHITE, 0.05f));
|
||||||
|
for(int i = UI_WIDTH; i < 1920; i += 100) {
|
||||||
|
DrawLineEx((Vector2){i, 0}, (Vector2){i, 1080}, gridThick, Fade(WHITE, gridAlpha));
|
||||||
|
}
|
||||||
|
for(int i = 0; i < 1080; i += 100) {
|
||||||
|
DrawLineEx((Vector2){UI_WIDTH, i}, (Vector2){1920, i}, gridThick, Fade(WHITE, gridAlpha));
|
||||||
|
}
|
||||||
|
DrawMichelsonSchema(&mic);
|
||||||
|
DrawControlPanel(&mic);
|
||||||
|
DrawInterferenceViewGPU(&mic, currentViewBounds, shader, &isFullscreen);
|
||||||
|
EndTextureMode();
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(COLOR_BG);
|
||||||
|
Rectangle sourceRec = {0.0f, 0.0f, (float)target.texture.width, -(float)target.texture.height};
|
||||||
|
Rectangle destRec = { offsetX, offsetY, newWidth, newHeight };
|
||||||
|
DrawTexturePro(target.texture, sourceRec, destRec, (Vector2){0, 0}, 0.0f, WHITE);
|
||||||
|
EndDrawing();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main () {
|
int main () {
|
||||||
//SetConfigFlags(FLAG_MSAA_4X_HINT);
|
//SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||||
#if !defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
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
|
#endif
|
||||||
|
|
||||||
InitWindow(1920, 1080, "Interferometre de Michelson");
|
SetTargetFPS(0);
|
||||||
SetTargetFPS(144);
|
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
shader = LoadShader(0, "glsl/michelson_web.frag");
|
shader = LoadShader(0, "glsl/michelson_web.frag");
|
||||||
@ -500,6 +540,11 @@ int main () {
|
|||||||
shader = LoadShader(0, "glsl/michelson.frag");
|
shader = LoadShader(0, "glsl/michelson.frag");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(PLATFORM_WEB)
|
||||||
|
target = LoadRenderTexture(1920, 1080);
|
||||||
|
SetTextureFilter(target.texture, TEXTURE_FILTER_BILINEAR);
|
||||||
|
#endif
|
||||||
|
|
||||||
mic.center = (Vector2){ UI_WIDTH + (1920 - UI_WIDTH) / 2.0f - 100, 1080 / 2.0f };
|
mic.center = (Vector2){ UI_WIDTH + (1920 - UI_WIDTH) / 2.0f - 100, 1080 / 2.0f };
|
||||||
mic.d1 = 250.0f;
|
mic.d1 = 250.0f;
|
||||||
mic.d2 = 250.0f;
|
mic.d2 = 250.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user