diff --git a/src/main.cpp b/src/main.cpp index 533f505..425d1eb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -136,6 +136,12 @@ std::vector GetMprisServices() { return ret; } +float ScaleToFit(Vector2 src, Vector2 dst) { + float ratio = std::min(dst.x/src.x, dst.y/src.y); + return ratio; + //return Vector2Scale(src, ratio); +} + int main(int argc, char *argv[]) { // Initialization //-------------------------------------------------------------------------------------- @@ -145,7 +151,7 @@ int main(int argc, char *argv[]) { // SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE); SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE); InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - Docking"); - SetTargetFPS(120); + SetTargetFPS(244); rlImGuiSetup(true); ImGui::GetStyle().AntiAliasedLinesUseTex = false; @@ -197,7 +203,6 @@ int main(int argc, char *argv[]) { while (!WindowShouldClose() && run) // Detect window close button or ESC key, or a quit from the menu { - if (GetTime() > lasttime+3 ) { lasttime = GetTime(); current_player.Refresh(); @@ -206,6 +211,10 @@ int main(int argc, char *argv[]) { BeginDrawing(); ClearBackground(DARKGRAY); + Vector2 winwidth = (Vector2) {(float) GetScreenWidth(), (float) GetScreenHeight()}; + Vector2 imagesize = (Vector2) {(float) current_player.tex.tex.width, (float) current_player.tex.tex.height}; + DrawTextureEx(current_player.tex.tex, (Vector2) {0,0}, 0, ScaleToFit(imagesize, winwidth), WHITE); + // start ImGui content rlImGuiBegin(); diff --git a/src/mpris_connection.cpp b/src/mpris_connection.cpp index fecaf2a..1360bcf 100644 --- a/src/mpris_connection.cpp +++ b/src/mpris_connection.cpp @@ -128,18 +128,24 @@ void MprisPlayer::UpdateTexture() { RayTexture::RayTexture() { tex = LoadTexture(ASSET_DIR "/null.png" ); + GenTextureMipmaps(&tex); + SetTextureFilter(tex, TEXTURE_FILTER_BILINEAR); path = ASSET_DIR "/null.png"; } RayTexture::RayTexture(Image img) { path = "NOPATH"; tex = LoadTextureFromImage(img); + GenTextureMipmaps(&tex); + SetTextureFilter(tex, TEXTURE_FILTER_BILINEAR); } RayTexture::RayTexture(const RayTexture &other) { path = other.path; auto img = LoadImageFromTexture(other.tex); tex = LoadTextureFromImage(img); + GenTextureMipmaps(&tex); + SetTextureFilter(tex, TEXTURE_FILTER_BILINEAR); UnloadImage(img); }