Update Database

Database is more usable now.
All pages have been updated to use the database, and share an application configuration.
Page Stack has been removed, no more pages hanging around in memory. Replaced with a 'Router' which uses an Enum to determine which page should be displayed, destroys the old page and initializes the new page all in one go. No more push, pop, rollback, etc. No more holding instances of pages.
Logger has been updated with proper timestamps and sorting now works as expected."
This commit is contained in:
NeilClack
2026-03-23 15:02:07 -05:00
parent f8fbfb721d
commit 17c088cc2f
28 changed files with 537 additions and 2276 deletions
+5 -12
View File
@@ -8,7 +8,6 @@ import (
"sync"
"github.com/go-gl/gl/v3.3-core/gl"
"rhemawavetech.com/rhemawave/internal/db"
)
// Shader represents a compiled GLSL program and its associated data.
@@ -35,14 +34,14 @@ var (
)
// InitShaderManager initializes the ShaderManager singleton.
func InitShaderManager() error {
func InitShaderManager(shaderDir string) error {
var err error
once.Do(func() {
sm := &ShaderManager{
shaders: make(map[string]*Shader),
}
if e := sm.LoadShaders(); e != nil {
err = fmt.Errorf("could not load shaders: %w", e)
if e := sm.LoadShaders(shaderDir); e != nil {
err = fmt.Errorf("could not load shaders from %s: %w", shaderDir, e)
return
}
instance = sm
@@ -78,17 +77,11 @@ func (sm *ShaderManager) Close() {
}
// LoadShaders scans a directory for .vert and .frag files and creates a shader program for each pair.
func (sm *ShaderManager) LoadShaders() error {
func (sm *ShaderManager) LoadShaders(shaderDir string) error {
// Get assets directory from database
assetsDir, err := db.GetConfigValue("assets_dir")
if err != nil {
return fmt.Errorf("retrieving assets_dir from db: %w", err)
}
srcDir := filepath.Join(assetsDir, "shaders")
shaderFiles := make(map[string]string)
err = filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error {
err := filepath.Walk(shaderDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}