feat: install process

This commit is contained in:
2025-09-06 16:28:38 +02:00
parent f37216f4c7
commit 748141d30c
3 changed files with 55 additions and 5 deletions

View File

@@ -69,7 +69,21 @@ Vector2 hyprland_get_cursor_position()
Texture2D load_texture_from_file(const char *file_path)
{
Texture2D texture = LoadTexture(file_path);
Texture2D texture = {0};
if (FileExists(file_path))
{
texture = LoadTexture(file_path);
}
else
{
const char *system_path = TextFormat("/usr/share/wallpaper/%s", file_path);
if (FileExists(system_path))
{
texture = LoadTexture(system_path);
}
}
if (texture.id == 0)
{
TraceLog(LOG_ERROR, "Failed to load texture from file: %s", file_path);
@@ -77,6 +91,31 @@ Texture2D load_texture_from_file(const char *file_path)
return texture;
}
Shader load_shader_from_file(const char *vs_path, const char *fs_path)
{
Shader shader = {0};
if (FileExists(vs_path) && FileExists(fs_path))
{
shader = LoadShader(vs_path, fs_path);
}
else
{
const char *system_vs_path = TextFormat("/usr/share/wallpaper/%s", vs_path);
const char *system_fs_path = TextFormat("/usr/share/wallpaper/%s", fs_path);
if (FileExists(system_vs_path) && FileExists(system_fs_path))
{
shader = LoadShader(system_vs_path, system_fs_path);
}
}
if (shader.id == 0)
{
TraceLog(LOG_ERROR, "Failed to load shader from files: %s, %s", vs_path, fs_path);
}
return shader;
}
int main(void)
{
InitWindow(WIDTH, HEIGHT, "pihkaal-wallpaper");
@@ -92,7 +131,7 @@ int main(void)
RenderTexture2D target = LoadRenderTexture(WIDTH, HEIGHT);
// initialize shader
Shader shader = LoadShader("resources/shaders/basic.vs", "resources/shaders/distance_field.fs");
Shader shader = load_shader_from_file("resources/shaders/basic.vs", "resources/shaders/distance_field.fs");
int resolutionLoc = GetShaderLocation(shader, "resolution");
int mousePosLoc = GetShaderLocation(shader, "mousePos");
@@ -142,8 +181,6 @@ int main(void)
DrawTextureRec(backgroundTex, (Rectangle){0, 0, screenWidth, screenHeight}, (Vector2){0, 0}, WHITE);
DrawText(TextFormat("Distance Field | x: %.0f, y: %.0f | frame: %.2f ms", mousePos.x, mousePos.y, GetFrameTime() * 1000), 10, 10, 20, WHITE);
EndDrawing();
}